Skip to content

Commit da47ede

Browse files
committed
factorize memory fill
1 parent 64a0f96 commit da47ede

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

console.S

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ cmd_rdmsr:
250250
# CPUID
251251
cmd_cpuid:
252252
cmp al, OP_CPUID
253-
jne cmd_read_range
253+
jne cmd_fill_range
254254
movd eax, mm0
255255
cpuid
256256
movd mm0, eax
@@ -260,35 +260,28 @@ cmd_cpuid:
260260
jmp read_command
261261

262262
# Read memory range
263-
cmd_read_range:
263+
cmd_fill_range:
264264
cmp al, OP_READ_RANGE
265-
jne cmd_write_range
266-
# TODO: factorize this with write range
265+
je 0f
266+
cmp al, OP_WRITE_RANGE
267+
jne cmd_exit
268+
0: mov bl, al
267269
movd eax, mm0
268270
mov di, ax
269271
xor ax, ax
270272
shr eax, 4
271273
mov es, ax
272274
movd ecx, mm2
273275
shr ecx, 2
274-
# TODO: rep lods
276+
cmp bl, OP_READ_RANGE
277+
jne cmd_write_range
278+
# NB rep lods & rep stos don't work here
275279
0: mov eax, es:[di]
276280
add di, 4
277281
loop 0b
278282
jmp read_command
279-
280283
cmd_write_range:
281-
cmp al, OP_WRITE_RANGE
282-
jne cmd_exit
283-
movd eax, mm0
284-
mov di, ax
285-
xor ax, ax
286-
shr eax, 4
287-
mov es, ax
288-
movd ecx, mm2
289-
shr ecx, 2
290284
mov eax, 0xcbcbcbcb # RETF
291-
# TODO: rep stos
292285
0: mov es:[di], eax
293286
add di, 4
294287
loop 0b

0 commit comments

Comments
 (0)