/kernel/trunk/blkdev/disk.inc |
---|
335,8 → 335,7 |
push ebx esi ; save used registers to be stdcall |
; 1. Allocate the DISK structure. |
; 1a. Call the heap manager. |
push sizeof.DISK |
pop eax |
movi eax, sizeof.DISK |
call malloc |
; 1b. Check the result. If allocation failed, return (go to 9) with eax = 0. |
test eax, eax |
608,15 → 607,13 |
; The default implementation of DISKFUNC.querymedia. |
disk_default_querymedia: |
push DISK_STATUS_INVALID_CALL |
pop eax |
movi eax, DISK_STATUS_INVALID_CALL |
ret 8 |
; The default implementation of DISKFUNC.read and DISKFUNC.write. |
disk_default_read: |
disk_default_write: |
push DISK_STATUS_INVALID_CALL |
pop eax |
movi eax, DISK_STATUS_INVALID_CALL |
ret 20 |
; The default implementation of DISKFUNC.close, DISKFUNC.closemedia and |
1002,8 → 999,7 |
jnz .success |
; 3. No file system has recognized the volume, so just allocate the PARTITION |
; structure without extra fields. |
push sizeof.PARTITION |
pop eax |
movi eax, sizeof.PARTITION |
call malloc |
test eax, eax |
jz .nothing |
/kernel/trunk/blkdev/rd.inc |
---|
1252,8 → 1252,7 |
stosd |
pop edi |
xor eax, eax |
push 8 |
pop ebx |
movi ebx, 8 |
lea ecx, [edi+8] |
.loop: |
lodsb |
1538,8 → 1537,7 |
push ecx edi |
mov ecx, 8 |
repnz scasb |
push 1 |
pop eax ; 1 entry |
movi eax, 1 ; 1 entry |
jnz .notilde |
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total |
xor eax, eax |
1764,8 → 1762,7 |
add esp, 20 |
mov [esp+16], ebx |
popad |
push ERROR_DISK_FULL |
pop eax |
movi eax, ERROR_DISK_FULL |
ret |
.writedir: |
mov edi, eax |
1957,8 → 1954,7 |
jb @b |
.fat_err: |
pop ecx |
push ERROR_FAT_TABLE |
pop eax |
movi eax, ERROR_FAT_TABLE |
stc |
ret |
@@: |
2033,8 → 2029,7 |
pop edi ecx |
pop esi edx |
stc |
push ERROR_DISK_FULL |
pop eax |
movi eax, ERROR_DISK_FULL |
ret |
fat_update_datetime: |
/kernel/trunk/bootloader/extended_primary_loader/cdfs/bootsect.asm |
---|
50,8 → 50,7 |
; get file system information |
; scan for Primary Volume Descriptor |
db 66h |
push 10h-1 |
pop eax |
movi eax, 10h-1 |
pvd_scan_loop: |
mov cx, 1 |
inc eax |
/kernel/trunk/bus/pci/pci32.inc |
---|
680,8 → 680,7 |
jmp .no_device |
.has_device: |
push eax |
push sizeof.PCIDEV |
pop eax |
movi eax, sizeof.PCIDEV |
call malloc |
pop ecx |
test eax, eax |
/kernel/trunk/bus/usb/ehci.inc |
---|
330,8 → 330,7 |
; 2b. Fill first 32 entries. |
inc eax |
inc eax ; set Type to EHCI_TYPE_QH |
push 32 |
pop ecx |
movi ecx, 32 |
mov edx, ecx |
@@: |
stosd |
434,14 → 433,12 |
; now edi = MMIOBase2 |
; 6. Transfer the controller to a known state. |
; 6b. Stop the controller if it is running. |
push 10 |
pop ecx |
movi ecx, 10 |
test dword [edi+EhciStatusReg], 1 shl 12 |
jnz .stopped |
and dword [edi+EhciCommandReg], not 1 |
@@: |
push 1 |
pop esi |
movi esi, 1 |
call delay_ms |
test dword [edi+EhciStatusReg], 1 shl 12 |
jnz .stopped |
451,11 → 448,9 |
.stopped: |
; 6c. Reset the controller. Wait up to 50 ms checking status every 1 ms. |
or dword [edi+EhciCommandReg], 2 |
push 50 |
pop ecx |
movi ecx, 50 |
@@: |
push 1 |
pop esi |
movi esi, 1 |
call delay_ms |
test dword [edi+EhciCommandReg], 2 |
jz .reset_ok |
515,8 → 510,7 |
test byte [esi+ehci_controller.StructuralParams-sizeof.ehci_controller], 10h |
jz @f |
push esi |
push 20 |
pop esi |
movi esi, 20 |
call delay_ms |
pop esi |
@@: |
676,8 → 670,7 |
test al, 1 |
jz .has_ownership |
push esi |
push 1 |
pop esi |
movi esi, 1 |
call delay_ms |
pop esi |
dec dword [esp] |
862,8 → 855,7 |
push eax ecx |
sub edi, ehci_pipe.SoftwarePart |
xor eax, eax |
push ehci_pipe.SoftwarePart/4 |
pop ecx |
movi ecx, ehci_pipe.SoftwarePart/4 |
rep stosd |
pop ecx eax |
; 2. Setup PID in the first TD and make sure that the it is not active. |
883,8 → 875,7 |
and eax, 3FFF0000h |
; Use 1 requests per microframe for control/bulk endpoints, |
; use value from the endpoint descriptor for periodic endpoints |
push 1 |
pop edx |
movi edx, 1 |
test [.type], 1 |
jz @f |
mov edx, [.maxpacket] |
1292,8 → 1283,7 |
@@: |
; 3. Call the worker procedure to notify the protocol layer |
; about new EHCI device. It is high-speed. |
push USB_SPEED_HS |
pop eax |
movi eax, USB_SPEED_HS |
call ehci_new_device |
test eax, eax |
jnz .nothing |
1794,8 → 1784,7 |
; all corresponding bits are set. In this case, return some error code, |
; the order is quite arbitrary. |
pop eax ; status |
push USB_STATUS_UNDERRUN |
pop ecx |
movi ecx, USB_STATUS_UNDERRUN |
test al, 40h ; not Halted? |
jz .know_error |
mov cl, USB_STATUS_OVERRUN |
/kernel/trunk/bus/usb/hccommon.inc |
---|
398,8 → 398,7 |
jnc @f |
or byte [esp], 1 shl CONTROL_PIPE |
@@: |
push 4 |
pop edx |
movi edx, 4 |
call usb_process_one_wait_list |
jnc @f |
or byte [esp], 1 shl INTERRUPT_PIPE |
/kernel/trunk/bus/usb/hub.inc |
---|
253,8 → 253,7 |
; 2a. Save registers. |
push edx |
; 2b. Call the allocator. |
push 40 |
pop eax |
movi eax, 40 |
call malloc |
; 2c. Restore registers. |
pop ecx |
/kernel/trunk/bus/usb/init.inc |
---|
131,8 → 131,7 |
proc create_usb_thread |
; 1. Create the thread. |
push edi |
push 1 |
pop ebx |
movi ebx, 1 |
mov ecx, usb_thread_proc |
xor edx, edx |
call new_sys_threads |
/kernel/trunk/bus/usb/ohci.inc |
---|
351,8 → 351,7 |
lea esi, [eax+ohci_controller.IntEDs+32*sizeof.ohci_static_ep] |
call get_pg_addr |
add eax, ohci_controller.IntEDs |
push 32 |
pop ecx |
movi ecx, 32 |
mov edx, ecx |
@@: |
stosd |
429,10 → 428,8 |
; 5c. Save FmInterval register. |
pushd [edi+OhciFmIntervalReg] |
; 5d. Issue software reset and wait up to 10ms, checking status every 1 ms. |
push 1 |
pop ecx |
push 10 |
pop edx |
movi ecx, 1 |
movi edx, 10 |
mov [edi+OhciCommandStatusReg], ecx |
@@: |
mov esi, ecx |
633,14 → 630,12 |
; (This should generate SMI, BIOS should release its ownership in SMI handler.) |
mov dword [eax+OhciCommandStatusReg], 8 |
; 4c. Wait for result no more than 50 ms, checking for status every 1 ms. |
push 50 |
pop ecx |
movi ecx, 50 |
@@: |
test dword [eax+OhciControlReg], edx |
jz .has_ownership |
push esi |
push 1 |
pop esi |
movi esi, 1 |
call delay_ms |
pop esi |
loop @b |
984,8 → 979,7 |
; if so, return an error. |
lea edx, [esi + ohci_controller.IntEDs - sizeof.ohci_controller] |
lea eax, [esi + ohci_controller.IntEDs + 32*sizeof.ohci_static_ep - sizeof.ohci_controller] |
push 64 |
pop ecx |
movi ecx, 64 |
call usb1_select_interrupt_list |
test edx, edx |
jz .return0 |
/kernel/trunk/bus/usb/scheduler.inc |
---|
206,8 → 206,7 |
sub ecx, 3 |
cmp ecx, 5 ; maximum 32ms |
jbe @f |
push 5 |
pop ecx |
movi ecx, 5 |
@@: |
; There are four nested loops, |
; * Loop #4 (the innermost one) calculates the total periodic bandwidth |
221,10 → 220,8 |
; ebx = number of iterations of loop #1 |
; [esp] = delta of counter for loop #3, in bytes |
; [esp+4] = delta between the first group and the target group, in bytes |
push 1 |
pop ebx |
push sizeof.ehci_static_ep |
pop edx |
movi ebx, 1 |
movi edx, sizeof.ehci_static_ep |
shl ebx, cl |
shl edx, cl |
mov eax, 64*sizeof.ehci_static_ep |
282,8 → 279,7 |
ja @f |
mov [.bandwidth], edi |
mov [.target], edx |
push 1 |
pop eax |
movi eax, 1 |
shl eax, cl |
mov [.targetsmask], eax |
@@: |
317,8 → 313,7 |
mov ecx, [.targetsmask] |
add [edx+ehci_static_ep.Bandwidths+ecx*2], ax |
add edx, ehci_static_ep.SoftwarePart |
push 1 |
pop eax |
movi eax, 1 |
shl eax, cl |
pop edi ebx ; restore used registers to be stdcall |
ret |
371,8 → 366,7 |
end virtual |
; 10. Select the best variant. |
; edx = S-Mask = bitmask of scheduled microframes |
push 0x11 |
pop edx |
movi edx, 0x11 |
cmp ecx, 1 |
ja @f |
mov dl, 0x55 |
/kernel/trunk/bus/usb/uhci.inc |
---|
315,8 → 315,7 |
; 2b. Fill first 32 entries. |
inc eax |
inc eax ; set QH bit for uhci_pipe.NextQH |
push 32 |
pop ecx |
movi ecx, 32 |
mov edx, ecx |
@@: |
stosd |
416,12 → 415,10 |
mov ax, 2 |
out dx, ax |
; 5f. Wait up to 10ms. |
push 10 |
pop ecx |
movi ecx, 10 |
@@: |
push esi |
push 1 |
pop esi |
movi esi, 1 |
call delay_ms |
pop esi |
in ax, dx |
435,8 → 432,7 |
; emergency variant for tests - always wait 10 ms |
; wait 10 ms |
push esi |
push 10 |
pop esi |
movi esi, 10 |
call delay_ms |
pop esi |
; clear reset signal |
998,8 → 994,7 |
; * if several non-fatal errors have occured during transaction retries, |
; all corresponding bits are set. In this case, return some error code, |
; the order is quite arbitrary. |
push USB_STATUS_UNDERRUN |
pop ecx |
movi ecx, USB_STATUS_UNDERRUN |
test al, 1 shl (22-16) ; not Stalled? |
jz .know_error |
mov cl, USB_STATUS_OVERRUN |
1260,8 → 1255,7 |
; 2. Status bits in UHCI are invalid during reset signalling. |
; Wait a millisecond while status bits become valid again. |
push esi |
push 1 |
pop esi |
movi esi, 1 |
call delay_ms |
pop esi |
; 3. ConnectStatus bit is zero during reset and becomes 1 during step 2; |
1458,8 → 1452,7 |
; if so, return an error. |
lea edx, [esi + uhci_controller.IntEDs - sizeof.uhci_controller] |
lea eax, [esi + uhci_controller.IntEDs + 32*sizeof.uhci_static_ep - sizeof.uhci_controller] |
push 64 |
pop ecx |
movi ecx, 64 |
call usb1_select_interrupt_list |
test edx, edx |
jz .return0 |
/kernel/trunk/core/sys32.inc |
---|
504,8 → 504,7 |
mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
test eax, eax |
jz .nodebug |
push 8 |
pop ecx |
movi ecx, 8 |
push dword [CURRENT_TASK+edi+TASKDATA.pid]; PID |
push 2 |
call debugger_notify |
/kernel/trunk/core/timers.inc |
---|
82,8 → 82,7 |
timerFunc:dword, userData:dword |
; 1. Allocate memory for the TIMER structure. |
; 1a. Call the allocator. |
push sizeof.TIMER |
pop eax |
movi eax, sizeof.TIMER |
call malloc |
; 1b. If allocation failed, return (go to 5) with eax = 0. |
test eax, eax |
/kernel/trunk/drivers/fdo.inc |
---|
19,6 → 19,20 |
; __DEBUG__ equ 1 |
; __DEBUG_LEVEL__ equ 5 |
; MOV Immediate. |
; Useful for things like movi eax,10: |
; shorter than regular mov, but slightly slower, |
; do not use it in performance-critical places. |
macro movi dst, imm |
{ |
if imm >= -0x80 & imm <= 0x7F |
push imm |
pop dst |
else |
mov dst, imm |
end if |
} |
macro debug_func name { |
if used name |
name@of@func equ name |
273,8 → 287,7 |
call fdo_debug_outchar |
pop eax |
@@: |
push 10 |
pop ecx |
movi ecx, 10 |
push -'0' |
.l1: |
xor edx, edx |
/kernel/trunk/drivers/usbhid.asm |
---|
234,8 → 234,7 |
; 8 bytes for a packet and 8 bytes for previous packet, used by a keyboard. |
; 9. Initialize device data. |
mov [ebx+device_data.intpipe], eax |
push 8 |
pop ecx |
movi ecx, 8 |
cmp edx, ecx |
jb @f |
mov edx, ecx |
364,8 → 363,7 |
jb .controlloop |
.nocontrol: |
; 3. Initialize before loop for normal keys. esi = index. |
push 2 |
pop esi |
movi esi, 2 |
.normalloop: |
; 4. Process one key which was pressed in the previous packet. |
; 4a. Get the next pressed key from the previous packet. |
486,8 → 484,7 |
; Auxiliary procedure for keyboard_data_ready. |
haskey: |
push 2 |
pop edx |
movi edx, 2 |
@@: |
cmp byte [ecx+edx], al |
jz @f |
/kernel/trunk/drivers/usbstor.asm |
---|
298,8 → 298,7 |
.UserData dd ? ; request_queue_item.UserData |
end virtual |
; 1. Allocate the memory for the request description. |
push request_queue_item.sizeof |
pop eax |
movi eax, request_queue_item.sizeof |
call Kmalloc |
test eax, eax |
jnz @f |
1004,10 → 1003,8 |
; 4. Thus, create a temporary kernel thread which would do it. |
mov edx, [esp+8] |
push ebx ecx |
push 51 |
pop eax |
push 1 |
pop ebx |
movi eax, 51 |
movi ebx, 1 |
mov ecx, new_disk_thread |
; edx = parameter |
int 0x40 |
1069,8 → 1066,7 |
cmp [edx+usb_unit_data.UnitReadyAttempts], 3 |
jz @f |
push ecx edx esi |
push 10 |
pop esi |
movi esi, 10 |
call Sleep |
pop esi edx ecx |
stdcall queue_request, ecx, test_unit_ready_req, 0, test_unit_ready_callback, edx |
1124,8 → 1120,7 |
mov byte [edi-1], 'd' |
push eax |
push -'0' |
push 10 |
pop ecx |
movi ecx, 10 |
@@: |
cdq |
div ecx |
/kernel/trunk/fdo.inc |
---|
278,8 → 278,7 |
call fdo_debug_outchar |
pop eax |
@@: |
push 10 |
pop ecx |
movi ecx, 10 |
push -'0' |
.l1: |
xor edx, edx |
/kernel/trunk/fs/fat12.inc |
---|
1311,8 → 1311,7 |
push ecx edi |
mov ecx, 8 |
repnz scasb |
push 1 |
pop eax ; 1 entry |
movi eax, 1 ; 1 entry |
jnz .notilde |
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total |
xor eax, eax |
1822,8 → 1821,7 |
jb @b |
.fat_err: |
pop ecx |
push ERROR_FAT_TABLE |
pop eax |
movi eax, ERROR_FAT_TABLE |
stc |
ret |
@@: |
1885,8 → 1883,7 |
pop edi ecx |
pop esi edx |
stc |
push ERROR_DISK_FULL |
pop eax |
movi eax, ERROR_DISK_FULL |
ret |
;---------------------------------------------------------------- |
/kernel/trunk/fs/fat32.inc |
---|
167,8 → 167,7 |
; in the normal operation, let's hope for the best and allocate data now; if |
; it will prove wrong, just deallocate it. |
push ebx |
push sizeof.FAT |
pop eax |
movi eax, sizeof.FAT |
call malloc |
pop ebx |
test eax, eax |
972,8 → 971,7 |
jz ntfs_HdReadFolder |
cmp [fs_type], 2 |
jz ext2_HdReadFolder |
push ERROR_UNSUPPORTED_FS |
pop eax |
movi eax, ERROR_UNSUPPORTED_FS |
or ebx, -1 |
ret |
@@: |
1659,8 → 1657,7 |
push ecx edi |
mov ecx, 8 |
repnz scasb |
push 1 |
pop eax ; 1 entry |
movi eax, 1 ; 1 entry |
jnz .notilde |
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total |
xor eax, eax |
2362,8 → 2359,7 |
jmp .device_err2 |
.disk_full: |
pop eax edx esi |
push ERROR_DISK_FULL |
pop eax |
movi eax, ERROR_DISK_FULL |
stc |
ret |
2390,8 → 2386,7 |
jz ntfs_HdSetFileEnd |
cmp [fs_type], 2 |
jz ext2_HdSetFileEnd |
push ERROR_UNKNOWN_FS |
pop eax |
movi eax, ERROR_UNKNOWN_FS |
ret |
@@: |
sub ebx, 4 |
2566,8 → 2561,7 |
pop eax ecx eax edi |
call update_disk |
call fat_unlock |
push ERROR_DEVICE |
pop eax |
movi eax, ERROR_DEVICE |
ret |
@@: |
; we will zero data at the end of last sector - remember it |
2640,8 → 2634,7 |
pop eax ecx eax edi |
call update_disk |
call fat_unlock |
push ERROR_FAT_TABLE |
pop eax |
movi eax, ERROR_FAT_TABLE |
ret |
fs_HdGetFileInfo: |
2771,8 → 2764,7 |
jz ntfs_HdDelete |
cmp [fs_type], 2 |
jz ext2_HdDelete |
push ERROR_UNKNOWN_FS |
pop eax |
movi eax, ERROR_UNKNOWN_FS |
ret |
@@: |
sub ebx, 4 |
2866,15 → 2858,13 |
.err2: |
pop edi |
call fat_unlock |
push ERROR_DEVICE |
pop eax |
movi eax, ERROR_DEVICE |
ret |
.error_fat: |
popad |
pop edi |
call fat_unlock |
push ERROR_FAT_TABLE |
pop eax |
movi eax, ERROR_FAT_TABLE |
ret |
.notempty: |
popad |
2881,8 → 2871,7 |
.access_denied2: |
pop edi |
call fat_unlock |
push ERROR_ACCESS_DENIED |
pop eax |
movi eax, ERROR_ACCESS_DENIED |
ret |
.empty: |
popad |
/kernel/trunk/fs/ntfs.inc |
---|
1139,15 → 1139,13 |
cmp byte [esi], 0 |
jnz @f |
or ebx, -1 |
push ERROR_ACCESS_DENIED |
pop eax |
movi eax, ERROR_ACCESS_DENIED |
ret |
@@: |
call ntfs_find_lfn |
jnc .found |
or ebx, -1 |
push ERROR_FILE_NOT_FOUND |
pop eax |
movi eax, ERROR_FILE_NOT_FOUND |
ret |
.found: |
mov [ntfs_cur_attr], 0x80 ; $DATA |
1156,8 → 1154,7 |
call ntfs_read_attr |
jnc @f |
or ebx, -1 |
push ERROR_ACCESS_DENIED |
pop eax |
movi eax, ERROR_ACCESS_DENIED |
ret |
@@: |
pushad |
1171,8 → 1168,7 |
popad |
xor ebx, ebx |
.eof: |
push ERROR_END_OF_FILE |
pop eax |
movi eax, ERROR_END_OF_FILE |
ret |
@@: |
mov eax, [ebx] |
1349,8 → 1345,7 |
.nomem: |
popad |
or ebx, -1 |
push 12 |
pop eax |
movi eax, 12 |
ret |
@@: |
mov [ntfs_data.cur_index_buf], eax |
1804,14 → 1799,12 |
ntfs_HdGetFileInfo: |
cmp byte [esi], 0 |
jnz @f |
push 2 |
pop eax |
movi eax, 2 |
ret |
@@: |
call ntfs_find_lfn |
jnc .doit |
push ERROR_FILE_NOT_FOUND |
pop eax |
movi eax, ERROR_FILE_NOT_FOUND |
cmp [hd_error], 0 |
jz @f |
mov al, 11 |
/kernel/trunk/hid/keyboard.inc |
---|
139,8 → 139,7 |
register_keyboard: |
push ebx |
push sizeof.KEYBOARD |
pop eax |
movi eax, sizeof.KEYBOARD |
call malloc |
test eax, eax |
jz .nothing |
/kernel/trunk/kernel.asm |
---|
5567,8 → 5567,7 |
ret |
@@: |
call stop_all_services |
push 3 ; stop playing cd |
pop eax |
movi eax, 3 |
call sys_cd_audio |
yes_shutdown_param: |
5576,8 → 5575,7 |
if ~ defined extended_primary_loader |
mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
push 12 |
pop esi |
movi esi, 12 |
xor ebx, ebx |
or ecx, -1 |
mov edx, OS_BASE+0x70000 |
/kernel/trunk/macros.inc |
---|
117,3 → 117,16 |
mov [ecx+list_fd], edx |
} |
; MOV Immediate. |
; Useful for things like movi eax,10: |
; shorter than regular mov, but slightly slower, |
; do not use it in performance-critical places. |
macro movi dst, imm |
{ |
if imm >= -0x80 & imm <= 0x7F |
push imm |
pop dst |
else |
mov dst, imm |
end if |
} |
/kernel/trunk/network/tcp.inc |
---|
160,8 → 160,7 |
init_queue TCP_queue |
push 1 |
pop ebx |
movi ebx, 1 |
mov ecx, TCP_process_input |
call new_sys_threads |
/kernel/trunk/sec_loader/trunk/boot/cdfs/bootsect.asm |
---|
50,8 → 50,7 |
; get file system information |
; scan for Primary Volume Descriptor |
db 66h |
push 10h-1 |
pop eax |
movi eax, 10h-1 |
pvd_scan_loop: |
mov cx, 1 |
inc eax |