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