merge flat kernel

git-svn-id: svn://kolibrios.org@465 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-04-18 06:37:14 +00:00
parent 4c272bed81
commit fef69aab20
59 changed files with 4558 additions and 3025 deletions

View File

@ -12,10 +12,10 @@ $Revision$
; Àâòîð èñõîäíîãî òåêñòà Êóëàêîâ Âëàäèìèð Ãåííàäüåâè÷. ; Àâòîð èñõîäíîãî òåêñòà Êóëàêîâ Âëàäèìèð Ãåííàäüåâè÷.
; Àäàïòàöèÿ è äîðàáîòêà Mario79 ; Àäàïòàöèÿ è äîðàáîòêà Mario79
give_back_application_data: ; ïåğåñëàòü ïğèëîæåíèş ;give_back_application_data: ; ïåğåñëàòü ïğèëîæåíèş
mov edi,[TASK_BASE] ; mov edi,[TASK_BASE]
mov edi,[edi+TASKDATA.mem_start] ; mov edi,[edi+TASKDATA.mem_start]
add edi,ecx ; add edi,ecx
give_back_application_data_1: give_back_application_data_1:
mov esi,FDD_BUFF ;FDD_DataBuffer ;0x40000 mov esi,FDD_BUFF ;FDD_DataBuffer ;0x40000
xor ecx,ecx xor ecx,ecx
@ -24,10 +24,10 @@ give_back_application_data_1:
rep movsd rep movsd
ret ret
take_data_from_application: ; âçÿòü èç ïğèëîæåíè ;take_data_from_application: ; âçÿòü èç ïğèëîæåíè
mov esi,[TASK_BASE] ; mov esi,[TASK_BASE]
mov esi,[esi+TASKDATA.mem_start] ; mov esi,[esi+TASKDATA.mem_start]
add esi,ecx ; add esi,ecx
take_data_from_application_1: take_data_from_application_1:
mov edi,FDD_BUFF ;FDD_DataBuffer ;0x40000 mov edi,FDD_BUFF ;FDD_DataBuffer ;0x40000
xor ecx,ecx xor ecx,ecx

View File

@ -400,7 +400,7 @@ clear_hd_cache:
save_hd_wait_timeout: save_hd_wait_timeout:
push eax push eax
mov eax,[timer_ticks];[0xfdf0] mov eax,[timer_ticks]
add eax,300 ; 3 sec timeout add eax,300 ; 3 sec timeout
mov [hd_wait_timeout],eax mov [hd_wait_timeout],eax
pop eax pop eax
@ -411,7 +411,7 @@ check_hd_wait_timeout:
push eax push eax
mov eax,[hd_wait_timeout] mov eax,[hd_wait_timeout]
cmp [timer_ticks], eax ;[0xfdf0],eax cmp [timer_ticks], eax
jg hd_timeout_error jg hd_timeout_error
pop eax pop eax
mov [hd_error],0 mov [hd_error],0
@ -430,8 +430,8 @@ hd_timeout_error:
; call clear_application_table_status ; call clear_application_table_status
; mov esi,hd_timeout_str ; mov esi,hd_timeout_str
; call sys_msg_board_str ; call sys_msg_board_str
DEBUGF 1,"K : FS - HD timeout\n" DEBUGF 1,"K : FS - HD timeout\n"
; jmp $
mov [hd_error],1 mov [hd_error],1
pop eax pop eax
ret ret
@ -442,7 +442,7 @@ hd_read_error:
; call clear_application_table_status ; call clear_application_table_status
; mov esi,hd_read_str ; mov esi,hd_read_str
; call sys_msg_board_str ; call sys_msg_board_str
DEBUGF 1,"K : FS - HD read error\n" DEBUGF 1,"K : FS - HD read error\n"
pop edx eax pop edx eax
ret ret
@ -450,17 +450,17 @@ hd_write_error:
; call clear_hd_cache ; call clear_hd_cache
; call clear_application_table_status ; call clear_application_table_status
; mov esi,hd_write_str ; mov esi,hd_write_str
; call sys_msg_board_str ; call sys_msg_board_str
DEBUGF 1,"K : FS - HD write error\n" DEBUGF 1,"K : FS - HD write error\n"
ret ret
hd_write_error_dma: hd_write_error_dma:
; call clear_hd_cache ; call clear_hd_cache
; call clear_application_table_status ; call clear_application_table_status
; mov esi, hd_write_str ; mov esi, hd_write_str
; call sys_msg_board_str ; call sys_msg_board_str
DEBUGF 1,"K : FS - HD read error\n" DEBUGF 1,"K : FS - HD read error\n"
pop esi pop esi
ret ret
@ -469,8 +469,8 @@ hd_lba_error:
; call clear_application_table_status ; call clear_application_table_status
; mov esi,hd_lba_str ; mov esi,hd_lba_str
; call sys_msg_board_str ; call sys_msg_board_str
DEBUGF 1,"K : FS - HD LBA error\n" DEBUGF 1,"K : FS - HD LBA error\n"
jmp LBA_read_ret jmp LBA_read_ret
align 4 align 4
@ -582,9 +582,9 @@ iglobal
align 4 align 4
; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary ; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary
IDE_descriptor_table: IDE_descriptor_table:
dd OS_BASE+284000h dd 0x284000
dw 2000h dw 0x2000
dw 8000h dw 0x8000
dma_cur_sector dd not 40h dma_cur_sector dd not 40h
irq14_func dd hdd_irq_null irq14_func dd hdd_irq_null
@ -613,20 +613,20 @@ hdd_irq14:
mov dx, [IDEContrRegsBaseAddr] mov dx, [IDEContrRegsBaseAddr]
mov al, 0 mov al, 0
out dx, al out dx, al
call update_counters ; call update_counters
mov ebx, [dma_process] ; mov ebx, [dma_process]
cmp [CURRENT_TASK], ebx ; cmp [CURRENT_TASK], ebx
jz .noswitch ; jz .noswitch
mov [dma_task_switched], 1 ; mov [dma_task_switched], 1
mov edi, [dma_slot_ptr] ; mov edi, [dma_slot_ptr]
mov eax, [CURRENT_TASK] ; mov eax, [CURRENT_TASK]
mov [dma_process], eax ; mov [dma_process], eax
mov eax, [TASK_BASE] ; mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax ; mov [dma_slot_ptr], eax
mov [CURRENT_TASK], ebx ; mov [CURRENT_TASK], ebx
mov [TASK_BASE], edi ; mov [TASK_BASE], edi
mov byte [0xFFFF], 1 ; mov byte [DONT_SWITCH], 1
call do_change_task ; call do_change_task
.noswitch: .noswitch:
popad popad
popfd popfd
@ -644,20 +644,20 @@ hdd_irq15:
add dx, 8 add dx, 8
mov al, 0 mov al, 0
out dx, al out dx, al
call update_counters ; call update_counters
mov ebx, [dma_process] ; mov ebx, [dma_process]
cmp [CURRENT_TASK], ebx ; cmp [CURRENT_TASK], ebx
jz .noswitch ; jz .noswitch
mov [dma_task_switched], 1 ; mov [dma_task_switched], 1
mov edi, [dma_slot_ptr] ; mov edi, [dma_slot_ptr]
mov eax, [CURRENT_TASK] ; mov eax, [CURRENT_TASK]
mov [dma_process], eax ; mov [dma_process], eax
mov eax, [TASK_BASE] ; mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax ; mov [dma_slot_ptr], eax
mov [CURRENT_TASK], ebx ; mov [CURRENT_TASK], ebx
mov [TASK_BASE], edi ; mov [TASK_BASE], edi
mov byte [0xFFFF], 1 ; mov byte [DONT_SWITCH], 1
call do_change_task ; call do_change_task
.noswitch: .noswitch:
popad popad
popfd popfd
@ -689,9 +689,10 @@ hd_read_dma:
pop eax pop eax
ret ret
.notread: .notread:
mov eax, IDE_descriptor_table-OS_BASE mov eax, IDE_descriptor_table
mov dword [eax+OS_BASE], 0x284000 mov dword [eax], 0x284000
mov word [eax+4+OS_BASE], 0x2000 mov word [eax+4], 0x2000
sub eax, OS_BASE
mov dx, [IDEContrRegsBaseAddr] mov dx, [IDEContrRegsBaseAddr]
cmp [hdbase], 0x1F0 cmp [hdbase], 0x1F0
jz @f jz @f
@ -774,7 +775,7 @@ write_cache_chain:
mov eax, IDE_descriptor_table mov eax, IDE_descriptor_table
mov edx, [cache_chain_pos] mov edx, [cache_chain_pos]
shl edx, 9 shl edx, 9
add edx, OS_BASE+0x610000 add edx, 0x610000
mov [eax], edx mov [eax], edx
movzx edx, [cache_chain_size] movzx edx, [cache_chain_size]
shl edx, 9 shl edx, 9
@ -785,10 +786,11 @@ write_cache_sector:
mov eax, IDE_descriptor_table mov eax, IDE_descriptor_table
mov edx, edi mov edx, edi
shl edx, 9 shl edx, 9
add edx, OS_BASE+0x610000 add edx, 0x610000
mov [eax], edx mov [eax], edx
mov word [eax+4], 0x200 mov word [eax+4], 0x200
do_write_dma: do_write_dma:
sub eax, OS_BASE
mov dx, [IDEContrRegsBaseAddr] mov dx, [IDEContrRegsBaseAddr]
cmp [hdbase], 0x1F0 cmp [hdbase], 0x1F0
jz @f jz @f

View File

@ -1,13 +1,13 @@
$Revision$ $Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; RAMDISK functions ;; ;; RAMDISK functions ;;
;; (C) 2004 Ville Turjanmaa, License: GPL ;; ;; (C) 2004 Ville Turjanmaa, License: GPL ;;
;; Addings by M.Lisovin ;; ;; Addings by M.Lisovin ;;
;; LFN support by diamond ;; ;; LFN support by diamond ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; calculate fat chain ; calculate fat chain
@ -1802,7 +1802,12 @@ fs_RamdiskRewrite:
jnz .disk_full2 jnz .disk_full2
dec edi dec edi
dec edi dec edi
lea eax, [edi-(RAMDISK_FAT)]
; lea eax, [edi-(RAMDISK_FAT)]
mov eax, edi
sub eax, RAMDISK_FAT
shr eax, 1 ; eax = cluster shr eax, 1 ; eax = cluster
mov word [edi], 0xFFF ; mark as last cluster mov word [edi], 0xFFF ; mark as last cluster
xchg edi, [esp] xchg edi, [esp]
@ -2294,7 +2299,7 @@ fs_RamdiskExecute:
mov ebx, [ebx+4] mov ebx, [ebx+4]
test ebx, ebx test ebx, ebx
jz @f jz @f
add ebx, std_application_base_address ; add ebx, std_application_base_address
@@: @@:
;---------------------------------------------------------------- ;----------------------------------------------------------------

View File

@ -20,119 +20,6 @@ $Revision$
; ;
;========================================================================== ;==========================================================================
; 16-bit data
org $+0x10000
old_ints_h:
dw 0x400
dd 0
dw 0
kernel_restart_bootblock:
db 1 ; version
dw 1 ; floppy image is in memory
dd 0 ; cannot save parameters
align 32
; GDT TABLE
gdts:
dw gdte-$-1
dd gdts
dw 0
; Attention! The order first four selectors not to change, is used in Fast System Call
; must be : os_code, os_data, app_code, app_data, ....
int_code_l:
os_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011010b
db 0x00
int_data_l:
os_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
app_code_l:
dw 0xFFFF
dw 0
db 0
db cpl3
dw G32+D32+0x8000+0x7;
app_data_l:
dw 0xFFFF
dw 0
db 0
db drw3
dw G32+D32+0x8000+0x7;
; --------------- APM ---------------------
apm_code_32:
dw 0x0f ; limit 64kb
db 0, 0, 0
dw 11010000b *256 +10011010b
db 0x00
apm_code_16:
dw 0x0f
db 0, 0, 0
dw 10010000b *256 +10011010b
db 0x00
apm_data_16:
dw 0x0f
db 0, 0, 0
dw 10010000b *256 +10010010b
db 0x00
; -----------------------------------------
graph_data_l:
dw 0x7ff
dw 0x0000
db 0x00
dw 11010000b *256 +11110010b
db 0x00
tss0_l:
; times (max_processes+10) dd 0,0
gdte = $ + (max_processes+10)*8
; videomodes table
gr_table:
dw 0x112+0100000000000000b , 640 , 480 ; 1
dw 0x115+0100000000000000b , 800 , 600 ; 2
dw 0x118+0100000000000000b , 1024 , 768 ; 3
dw 0x11B+0100000000000000b , 1280 , 1024 ; 4
dw 0x112 , 640 , 480 ; 5
dw 0x115 , 800 , 600 ; 6
dw 0x118 , 1024 , 768 ; 7
dw 0x11B , 1280 ,1024 ; 8
dw 0x13, 640, 480 ; 9
dw 0x12, 640, 480 ; 0
; table for move to extended memory (int 15h, ah=87h)
movedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
org $-0x10000
putchar: putchar:
; in: al=character ; in: al=character
@ -160,72 +47,6 @@ printplain:
popa popa
ret ret
; Now int 16 is used for keyboard support.
; This is shorter, simpler and more reliable.
if 0
getkey: push ecx
push edx
add ebx,0x0101
xor eax,eax
gk1:
in al,0x60
mov cl,al
gk0:
in al,0x60
cmp al,cl
je gk0
cmp ax,11
jg gk0
gk0_1:
mov cl,al
; add al,47
; mov [ds:keyinbs-0x10000],al
; mov si,keyinbs-0x10000
; call printplain
gk12:
in al,0x60
cmp al,cl
je gk12
cmp ax,240
jne gk13
mov al,cl
jmp gk14
gk13:
add cl,128
cmp al,cl
jne gk1
sub al,128
gk14:
movzx edx,bl
cmp eax,edx
jb gk1
movzx edx,bh
cmp eax,edx
jg gk1
test ebx,0x010000
jnz gk3
mov cx,0x1000
mov dx,cx
add eax,47
mov cx,ax
cmp cx,58
jb gk_nozero
sub cx,10
gk_nozero:
mov [ds:keyin-0x10000],cl
mov si,keyin-0x10000
call printplain
gk3:
sub eax,48
pop edx
pop ecx
ret
end if
getkey: getkey:
; get number in range [bl,bh] (bl,bh in ['0'..'9']) ; get number in range [bl,bh] (bl,bh in ['0'..'9'])
; in: bx=range ; in: bx=range
@ -258,17 +79,6 @@ macro _setcursor row,column
call setcursor call setcursor
} }
;pagetable_set:
;eax - physical address
;es:di - page table
;ecx - number of pages to map
; or al, 7
;@@:
; stosd
; add eax, 1000h
; loop @b
; ret
boot_read_floppy: boot_read_floppy:
push si push si
xor si, si xor si, si
@ -281,7 +91,7 @@ boot_read_floppy:
inc si inc si
cmp si, 10 cmp si, 10
jb @b jb @b
mov si, badsect-0x10000 mov si, badsect
sayerr_plain: sayerr_plain:
call printplain call printplain
jmp $ jmp $
@ -301,15 +111,11 @@ start_of_code:
; \begin{diamond}[02.12.2005] ; \begin{diamond}[02.12.2005]
cmp ax, 'KL' cmp ax, 'KL'
jnz @f jnz @f
mov word [cs:cfgmanager.loader_block-0x10000], si mov word [cs:cfgmanager.loader_block], si
mov word [cs:cfgmanager.loader_block+2-0x10000], ds mov word [cs:cfgmanager.loader_block+2], ds
@@: @@:
; \end{diamond}[02.12.2005] ; \end{diamond}[02.12.2005]
mov word [cs:bx_from_load - 0x10000], bx ; {SPraid}[13.03.2007]
; set up stack ; set up stack
mov ax, 3000h mov ax, 3000h
mov ss, ax mov ss, ax
@ -326,14 +132,14 @@ start_of_code:
if lang eq ru if lang eq ru
; Load & set russian VGA font (RU.INC) ; Load & set russian VGA font (RU.INC)
mov bp,RU_FNT1-10000h ; RU_FNT1 - First part mov bp, RU_FNT1 ; RU_FNT1 - First part
mov bx,1000h ; 768 bytes mov bx,1000h ; 768 bytes
mov cx,30h ; 48 symbols mov cx,30h ; 48 symbols
mov dx,80h ; 128 - position of first symbol mov dx,80h ; 128 - position of first symbol
mov ax,1100h mov ax,1100h
int 10h int 10h
mov bp,RU_FNT2-10000h ; RU_FNT2 -Second part mov bp,RU_FNT2 ; RU_FNT2 -Second part
mov bx,1000h ; 512 bytes mov bx,1000h ; 512 bytes
mov cx,20h ; 32 symbols mov cx,20h ; 32 symbols
mov dx,0E0h ; 224 - position of first symbol mov dx,0E0h ; 224 - position of first symbol
@ -341,7 +147,7 @@ if lang eq ru
int 10h int 10h
; End set VGA russian font ; End set VGA russian font
else if lang eq et else if lang eq et
mov bp,ET_FNT-10000h ; ET_FNT1 mov bp,ET_FNT ; ET_FNT1
mov bx,1000h ; mov bx,1000h ;
mov cx,255 ; 256 symbols mov cx,255 ; 256 symbols
mov dx,0h ; 0 - position of first symbol mov dx,0h ; 0 - position of first symbol
@ -353,23 +159,17 @@ end if
push 0xb800 push 0xb800
pop es pop es
xor di, di xor di, di
; mov si,d80x25-0x10000
; mov cx,80*25
; mov ah,1*16+15
; dfl1:
; lodsb
; stosw
; loop dfl1
mov ah, 1*16+15 mov ah, 1*16+15
; draw top ; draw top
mov si, d80x25_top - 0x10000 mov si, d80x25_top
mov cx, d80x25_top_num * 80 mov cx, d80x25_top_num * 80
@@: @@:
lodsb lodsb
stosw stosw
loop @b loop @b
; draw spaces ; draw spaces
mov si, space_msg - 0x10000 mov si, space_msg
mov cx, 25 - d80x25_top_num - d80x25_bottom_num mov cx, 25 - d80x25_top_num - d80x25_bottom_num
dfl1: dfl1:
push cx push cx
@ -383,14 +183,14 @@ dfl1:
pop cx pop cx
loop dfl1 loop dfl1
; draw bottom ; draw bottom
mov si, d80x25_bottom - 0x10000 mov si, d80x25_bottom
mov cx, d80x25_bottom_num * 80 mov cx, d80x25_bottom_num * 80
@@: @@:
lodsb lodsb
stosw stosw
loop @b loop @b
mov byte [space_msg-0x10000+80], 0 ; now space_msg is null terminated mov byte [space_msg+80], 0 ; now space_msg is null terminated
_setcursor d80x25_top_num,0 _setcursor d80x25_top_num,0
@ -410,58 +210,19 @@ dfl1:
and dx,bx and dx,bx
cmp ax,dx cmp ax,dx
jnz cpugood jnz cpugood
mov si,not386-0x10000 mov si,not386
sayerr: sayerr:
call print call print
jmp $ jmp $
cpugood: cpugood:
push 0
popf
sti
; set up esp ; set up esp
movzx esp, sp movzx esp, sp
; FLUSH 8042 KEYBOARD CONTROLLER
;// mike.dld [
; mov al,0xED
; out 0x60,al
; or cx,-1
; @@:
; in al,0x64
; test al,2
; jz @f
; loop @b
; @@:
; mov al,0
; out 0x60,al
; or cx,-1
; @@:
; in al,0x64
; test al,2
; jz @f
; loop @b
; @@:
;// mike.dld ]
; mov ecx,10000
; fl1:
; in al,0x64
; loop fl1
; test al,1
; jz fl2
; in al,0x60
; jmp fl1
; fl2:
;****************************************************************
; The function is modified Mario79
;*****************************************************************
; wait_kbd: ; variant 1
; mov cx,2500h ;çàäåðæêà ïîðÿäêà 10 ìñåê
; test_kbd:
; in al,64h ;÷èòàåì ñîñòîÿíèå êëàâèàòóðû
; test al,2 ;ïðîâåðêà áèòà ãîòîâíîñòè
; loopnz test_kbd
push 0 push 0
pop es pop es
and word [es:0x9031], 0 and word [es:0x9031], 0
@ -531,7 +292,7 @@ wait_loop: ; variant 2
; Write APM ver ---- ; Write APM ver ----
and ax, 0xf0f and ax, 0xf0f
add ax, '00' add ax, '00'
mov si, msg_apm - 0x10000 mov si, msg_apm
mov [si + 5], ah mov [si + 5], ah
mov [si + 7], al mov [si + 7], al
_setcursor 0, 3 _setcursor 0, 3
@ -544,26 +305,17 @@ wait_loop: ; variant 2
mov ax, 0x5303 ; Connect 32 bit mode interface mov ax, 0x5303 ; Connect 32 bit mode interface
xor bx, bx xor bx, bx
int 0x15 int 0x15
; init selectors
movzx eax, ax ; real-mode segment base address of protected-mode 32-bit code segment push 0
shl eax, 4 pop es
mov [apm_code_32 - 0x10000 + 2], ax
shr eax, 16 mov [es:0x9040], ebx
mov [apm_code_32 - 0x10000 + 4], al mov [es:0x9050], ax
movzx ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment mov [es:0x9052], cx
shl ecx, 4 mov [es:0x9054], dx
mov [apm_code_16 - 0x10000 + 2], cx
shr ecx, 16
mov [apm_code_16 - 0x10000 + 4], cl
movzx edx, dx ; real-mode segment base address of protected-mode 16-bit data segment
shl edx, 4
mov [apm_data_16 - 0x10000 + 2], dx
shr edx, 16
mov [apm_data_16 - 0x10000 + 4], dl
mov [es : 0x9040], ebx ; offset of APM entry point
apm_end: apm_end:
_setcursor d80x25_top_num, 0 _setcursor d80x25_top_num, 0
; -----------------------------------------
; DISPLAY VESA INFORMATION ; DISPLAY VESA INFORMATION
@ -573,14 +325,14 @@ apm_end:
mov di,0xa000 mov di,0xa000
int 0x10 int 0x10
cmp ax,0x004f cmp ax,0x004f
mov si, novesa-0x10000 mov si, novesa
jnz @f jnz @f
mov bx, word [es:di+0x12] mov bx, word [es:di+0x12]
shl ebx,16 shl ebx,16
mov [es:0x9050], ebx mov [es:0x9050], ebx
mov ax,[es:di+4] mov ax,[es:di+4]
add ax,'0'*256+'0' add ax,'0'*256+'0'
mov si,vervesa-0x10000 mov si,vervesa
mov [si+vervesa_off], ah mov [si+vervesa_off], ah
mov [si+vervesa_off+2], al mov [si+vervesa_off+2], al
@@: call print @@: call print
@ -593,13 +345,13 @@ cfgmanager:
; b) preboot_dma_write = use DMA write? ; b) preboot_dma_write = use DMA write?
; c) preboot_vrrm = use VRR? ; c) preboot_vrrm = use VRR?
; d) preboot_device = from what boot? ; d) preboot_device = from what boot?
mov di, preboot_graph-0x10000 mov di, preboot_graph
; check bootloader block ; check bootloader block
cmp [.loader_block-0x10000], -1 cmp [.loader_block], -1
jz .noloaderblock jz .noloaderblock
les bx, [.loader_block-0x10000] les bx, [.loader_block]
cmp byte [es:bx], 1 cmp byte [es:bx], 1
mov si, loader_block_error-0x10000 mov si, loader_block_error
jnz sayerr jnz sayerr
test byte [es:bx+1], 1 test byte [es:bx+1], 1
jz @f jz @f
@ -610,11 +362,11 @@ cfgmanager:
@@: @@:
.noloaderblock: .noloaderblock:
; determine default settings ; determine default settings
mov [.bSettingsChanged-0x10000], 0 mov [.bSettingsChanged], 0
cmp byte [di], 0 cmp byte [di], 0
jnz .preboot_gr_end jnz .preboot_gr_end
mov [di+preboot_gprobe-preboot_graph], 0 mov [di+preboot_gprobe-preboot_graph], 0
mov al, [vervesa+vervesa_off-0x10000] mov al, [vervesa+vervesa_off]
cmp al, 'x' cmp al, 'x'
jz .novesa jz .novesa
cmp al, '1' cmp al, '1'
@ -637,66 +389,66 @@ cfgmanager:
cmp [di+preboot_device-preboot_graph], 1 cmp [di+preboot_device-preboot_graph], 1
adc [di+preboot_device-preboot_graph], 0 adc [di+preboot_device-preboot_graph], 0
; notify user ; notify user
mov si, linef-0x10000 mov si, linef
call print call print
mov si, start_msg-0x10000 mov si, start_msg
call print call print
mov si, time_msg-0x10000 mov si, time_msg
call print call print
; get start time ; get start time
call .gettime call .gettime
mov [.starttime-0x10000], eax mov [.starttime], eax
mov word [.timer-0x10000], .newtimer mov word [.timer], .newtimer
mov word [.timer-0x10000+2], cs mov word [.timer+2], cs
.printcfg: .printcfg:
_setcursor 9,0 _setcursor 9,0
mov si, current_cfg_msg-0x10000 mov si, current_cfg_msg
call print call print
mov si, curvideo_msg-0x10000 mov si, curvideo_msg
call print call print
mov al, [preboot_graph-0x10000] mov al, [preboot_graph]
cmp al, 8 cmp al, 8
ja .pnovesa ja .pnovesa
mov dl, al mov dl, al
and eax, 3 and eax, 3
mov si, [modes_msg-0x10000+eax*2] mov si, [modes_msg+eax*2]
call printplain call printplain
mov si, modevesa20-0x10000 mov si, modevesa20
cmp dl, 4 cmp dl, 4
jbe @f jbe @f
mov si, modevesa12-0x10000 mov si, modevesa12
@@: @@:
call printplain call printplain
cmp dl, 4 cmp dl, 4
ja .x ja .x
mov si, probeno_msg-0x10000 mov si, probeno_msg
cmp [preboot_gprobe-0x10000], 2 cmp [preboot_gprobe], 2
jnz @f jnz @f
mov si, probeok_msg-0x10000 mov si, probeok_msg
@@: @@:
call printplain call printplain
.x: .x:
jmp .c jmp .c
.pnovesa: .pnovesa:
cmp al, 9 cmp al, 9
mov si, mode9-0x10000 mov si, mode9
jz @b jz @b
mov si, mode10-0x10000 mov si, mode10
jmp @b jmp @b
.c: .c:
mov si, linef-0x10000 mov si, linef
call printplain call printplain
mov si, dma_msg-0x10000 mov si, dma_msg
cmp [preboot_dma_write-0x10000], 1 cmp [preboot_dma_write], 1
call .say_on_off call .say_on_off
mov si, vrrm_msg-0x10000 mov si, vrrm_msg
cmp [preboot_vrrm-0x10000], 1 cmp [preboot_vrrm], 1
call .say_on_off call .say_on_off
mov si, preboot_device_msg-0x10000 mov si, preboot_device_msg
call print call print
mov al, [preboot_device-0x10000] mov al, [preboot_device]
and eax, 3 and eax, 3
mov si, [preboot_device_msgs-0x10000+eax*2] mov si, [preboot_device_msgs+eax*2]
call printplain call printplain
.wait: .wait:
_setcursor 25,0 ; out of screen _setcursor 25,0 ; out of screen
@ -705,8 +457,8 @@ cfgmanager:
push 0 push 0
pop es pop es
mov eax, [es:8*4] mov eax, [es:8*4]
mov [.oldtimer-0x10000], eax mov [.oldtimer], eax
mov eax, [.timer-0x10000] mov eax, [.timer]
mov [es:8*4], eax mov [es:8*4], eax
sti sti
; wait for keypressed ; wait for keypressed
@ -716,11 +468,11 @@ cfgmanager:
; restore timer interrupt ; restore timer interrupt
push 0 push 0
pop es pop es
mov eax, [.oldtimer-0x10000] mov eax, [.oldtimer]
mov [es:8*4], eax mov [es:8*4], eax
mov [.timer-0x10000], eax mov [.timer], eax
_setcursor 7,0 _setcursor 7,0
mov si, space_msg-0x10000 mov si, space_msg
call printplain call printplain
pop ax pop ax
; switch on key ; switch on key
@ -736,15 +488,15 @@ cfgmanager:
cmp al, 'd' cmp al, 'd'
jnz .wait jnz .wait
_setcursor 15,0 _setcursor 15,0
mov si,bdev-0x10000 mov si,bdev
call print call print
mov bx,'13' mov bx,'13'
call getkey call getkey
mov [preboot_device-0x10000], al mov [preboot_device], al
_setcursor 13,0 _setcursor 13,0
.d: .d:
mov [.bSettingsChanged-0x10000], 1 mov [.bSettingsChanged], 1
mov si, space_msg-0x10000 mov si, space_msg
call printplain call printplain
_setcursor 15,0 _setcursor 15,0
mov cx, 6 mov cx, 6
@ -754,46 +506,46 @@ cfgmanager:
jmp .printcfg jmp .printcfg
.change_a: .change_a:
_setcursor 15,0 _setcursor 15,0
mov si, gr_mode-0x10000 mov si, gr_mode
call printplain call printplain
mov bx, '09' mov bx, '09'
call getkey call getkey
mov [preboot_graph-0x10000], al mov [preboot_graph], al
cmp al, 4 cmp al, 4
ja @f ja @f
mov si, probetext-0x10000 mov si, probetext
call printplain call printplain
mov bx, '12' mov bx, '12'
call getkey call getkey
mov [preboot_gprobe-0x10000], al mov [preboot_gprobe], al
@@: @@:
_setcursor 10,0 _setcursor 10,0
jmp .d jmp .d
.change_b: .change_b:
_setcursor 15,0 _setcursor 15,0
mov si, ask_dma-0x10000 mov si, ask_dma
call print call print
mov bx, '12' mov bx, '12'
call getkey call getkey
mov [preboot_dma_write-0x10000], al mov [preboot_dma_write], al
_setcursor 11,0 _setcursor 11,0
jmp .d jmp .d
.change_c: .change_c:
_setcursor 15,0 _setcursor 15,0
mov si, vrrmprint-0x10000 mov si, vrrmprint
call print call print
mov bx, '12' mov bx, '12'
call getkey call getkey
mov [preboot_vrrm-0x10000], al mov [preboot_vrrm], al
_setcursor 12,0 _setcursor 12,0
jmp .d jmp .d
.say_on_off: .say_on_off:
pushf pushf
call print call print
mov si, on_msg-0x10000 mov si, on_msg
popf popf
jz @f jz @f
mov si, off_msg-0x10000 mov si, off_msg
@@: call printplain @@: call printplain
ret ret
; novesa and vervesa strings are not used at the moment of executing this code ; novesa and vervesa strings are not used at the moment of executing this code
@ -803,9 +555,7 @@ virtual at novesa
.bSettingsChanged db ? .bSettingsChanged db ?
.timer dd ? .timer dd ?
end virtual end virtual
org $+0x10000
.loader_block dd -1 .loader_block dd -1
org $-0x10000
.gettime: .gettime:
mov ah, 0 mov ah, 0
int 1Ah int 1Ah
@ -818,10 +568,10 @@ end virtual
push cs push cs
pop ds pop ds
pushf pushf
call [.oldtimer-0x10000] call [.oldtimer]
pushad pushad
call .gettime call .gettime
sub eax, [.starttime-0x10000] sub eax, [.starttime]
sub ax, 18*5 sub ax, 18*5
jae .timergo jae .timergo
neg ax neg ax
@ -838,12 +588,12 @@ if lang eq ru
mov cl, 'ã' mov cl, 'ã'
jz @f jz @f
mov cl, 'ë' mov cl, 'ë'
@@: mov [time_str+9-0x10000], cl @@: mov [time_str+9], cl
else if lang eq et else if lang eq et
cmp al, 1 cmp al, 1
ja @f ja @f
mov [time_str+9-0x10000], ' ' mov [time_str+9], ' '
mov [time_str+10-0x10000],' ' mov [time_str+10],' '
@@: @@:
else else
; wait 5/4/3/2 seconds, 1 second ; wait 5/4/3/2 seconds, 1 second
@ -851,11 +601,11 @@ else
mov cl, 's' mov cl, 's'
ja @f ja @f
mov cl, ' ' mov cl, ' '
@@: mov [time_str+9-0x10000], cl @@: mov [time_str+9], cl
end if end if
add al, '0' add al, '0'
mov [time_str+1-0x10000], al mov [time_str+1], al
mov si, time_msg-0x10000 mov si, time_msg
_setcursor 7,0 _setcursor 7,0
call print call print
_setcursor 25,0 _setcursor 25,0
@ -865,31 +615,31 @@ end if
.timergo: .timergo:
push 0 push 0
pop es pop es
mov eax, [.oldtimer-0x10000] mov eax, [.oldtimer]
mov [es:8*4], eax mov [es:8*4], eax
mov sp, 0EC00h mov sp, 0EC00h
.continue: .continue:
sti sti
_setcursor 6,0 _setcursor 6,0
mov si, space_msg-0x10000 mov si, space_msg
call printplain call printplain
call printplain call printplain
_setcursor 6,0 _setcursor 6,0
mov si, loading_msg-0x10000 mov si, loading_msg
call print call print
_setcursor 15,0 _setcursor 15,0
cmp [.bSettingsChanged-0x10000], 0 cmp [.bSettingsChanged], 0
jz .load jz .load
cmp [.loader_block-0x10000], -1 cmp [.loader_block], -1
jz .load jz .load
les bx, [.loader_block-0x10000] les bx, [.loader_block]
mov eax, [es:bx+3] mov eax, [es:bx+3]
push ds push ds
pop es pop es
test eax, eax test eax, eax
jz .load jz .load
push eax push eax
mov si, save_quest-0x10000 mov si, save_quest
call print call print
.waityn: .waityn:
mov ah, 0 mov ah, 0
@ -900,7 +650,7 @@ end if
cmp al, 'y' cmp al, 'y'
jnz .waityn jnz .waityn
call putchar call putchar
mov byte [space_msg-0x10000+80], 186 mov byte [space_msg+80], 186
pop eax pop eax
push cs push cs
push .cont push .cont
@ -911,7 +661,7 @@ end if
.cont: .cont:
push cs push cs
pop ds pop ds
mov si, space_msg-0x10000 mov si, space_msg
mov byte [si+80], 0 mov byte [si+80], 0
_setcursor 15,0 _setcursor 15,0
call printplain call printplain
@ -921,12 +671,12 @@ end if
; ASK GRAPHICS MODE ; ASK GRAPHICS MODE
movzx ax, [preboot_graph-0x10000] movzx ax, [preboot_graph]
push 0 push 0
pop es pop es
; address is gr_table+6*(ax-1)-0x10000 ; address is gr_table+6*(ax-1)
add ax, ax add ax, ax
lea si, [gr_table-0x10000 + eax + eax*2 - 6] lea si, [gr_table + eax + eax*2 - 6]
mov bx,[si+0] mov bx,[si+0]
mov cx,[si+2] mov cx,[si+2]
mov dx,[si+4] mov dx,[si+4]
@ -945,14 +695,14 @@ end if
; USE DEFAULTS OR PROBE ; USE DEFAULTS OR PROBE
; bx - mode : cx - x size : dx - y size ; bx - mode : cx - x size : dx - y size
cmp [preboot_gprobe-0x10000], 1 cmp [preboot_gprobe], 1
jz noprobe jz noprobe
mov bx,0x100 mov bx,0x100
newprobe: newprobe:
inc bx inc bx
cmp bx,0x17f cmp bx,0x17f
mov si,prnotfnd-0x10000 mov si,prnotfnd
jz sayerr jz sayerr
probemore: probemore:
@ -999,12 +749,12 @@ end if
mov [es:0x9000],al mov [es:0x9000],al
nov: nov:
cmp al,24 cmp al,24
mov si,bt24-0x10000 mov si,bt24
jz bppl jz bppl
cmp al,32 cmp al,32
mov si,bt32-0x10000 mov si,bt32
jz bppl jz bppl
mov si,btns-0x10000 mov si,btns
jmp sayerr jmp sayerr
bppl: bppl:
call print call print
@ -1033,26 +783,26 @@ end if
; DMA WRITE ; DMA WRITE
mov al, [preboot_dma_write-0x10000] mov al, [preboot_dma_write]
mov [es:0x901F],al mov [es:0x901F],al
; VRR_M USE ; VRR_M USE
mov al,[preboot_vrrm-0x10000] mov al,[preboot_vrrm]
mov [es:0x9030],al mov [es:0x9030],al
mov [es:0x901E],byte 1 mov [es:0x901E],byte 1
; BOOT DEVICE ; BOOT DEVICE
mov al, [preboot_device-0x10000] mov al, [preboot_device]
dec al dec al
mov [boot_dev-0x10000],al mov [boot_dev],al
; READ DISKETTE TO MEMORY ; READ DISKETTE TO MEMORY
; cmp [boot_dev-0x10000],0 ; cmp [boot_dev],0
jne no_sys_on_floppy jne no_sys_on_floppy
mov si,diskload-0x10000 mov si,diskload
call print call print
xor ax, ax ; reset drive xor ax, ax ; reset drive
xor dx, dx xor dx, dx
@ -1065,7 +815,7 @@ end if
mov bx, 0xB000 ; es:bx -> data area mov bx, 0xB000 ; es:bx -> data area
call boot_read_floppy call boot_read_floppy
; and copy them to extended memory ; and copy them to extended memory
mov si, movedesc-0x10000 mov si, movedesc
mov [si+8*2+3], bh mov [si+8*2+3], bh
push es push es
push ds push ds
@ -1079,7 +829,7 @@ sayerr_floppy:
mov dx, 0x3f2 mov dx, 0x3f2
mov al, 0 mov al, 0
out dx, al out dx, al
mov si, memmovefailed-0x10000 mov si, memmovefailed
jmp sayerr_plain jmp sayerr_plain
@@: @@:
add dword [si+8*3+2], 512*10 add dword [si+8*3+2], 512*10
@ -1168,7 +918,7 @@ sayerr_floppy:
aam aam
xchg al, ah xchg al, ah
add ax, '00' add ax, '00'
mov si, pros-0x10000 mov si, pros
cmp [si], ax cmp [si], ax
jz @f jz @f
mov [si], ax mov [si], ax
@ -1246,9 +996,10 @@ sayerr_floppy:
; jnz reads ; jnz reads
; readdone: ; readdone:
; pop ax ; pop ax
mov si,backspace2-0x10000
mov si,backspace2
call printplain call printplain
mov si,okt-0x10000 mov si,okt
call printplain call printplain
no_sys_on_floppy: no_sys_on_floppy:
xor ax, ax ; reset drive xor ax, ax ; reset drive
@ -1274,7 +1025,7 @@ sayerr_floppy:
setgr: setgr:
int 0x10 int 0x10
test ah,ah test ah,ah
mov si, fatalsel-0x10000 mov si, fatalsel
jnz sayerr jnz sayerr
; set mode 0x12 graphics registers: ; set mode 0x12 graphics registers:
cmp bx,0x12 cmp bx,0x12
@ -1302,4 +1053,3 @@ setgr:
gmok2: gmok2:
push ds push ds
pop es pop es

View File

@ -73,7 +73,7 @@ mode1 db "640x480",0
mode2 db "800x600",0 mode2 db "800x600",0
mode3 db "1024x768",0 mode3 db "1024x768",0
mode4 db "1280x1024",0 mode4 db "1280x1024",0
modes_msg dw mode4-0x10000,mode1-0x10000,mode2-0x10000,mode3-0x10000 modes_msg dw mode4,mode1,mode2,mode3
modevesa20 db " with LFB",0 modevesa20 db " with LFB",0
modevesa12 db ", VESA 1.2 Bnk",0 modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 colors",0 mode9 db "320x200, EGA/CGA 256 colors",0
@ -85,7 +85,7 @@ on_msg db " on",13,10,0
off_msg db " off",13,10,0 off_msg db " off",13,10,0
vrrm_msg db " [c] Use VRR:",0 vrrm_msg db " [c] Use VRR:",0
preboot_device_msg db " [d] Floppy image: ",0 preboot_device_msg db " [d] Floppy image: ",0
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000 preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "real floppy",13,10,0 pdm1 db "real floppy",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "use already loaded image",13,10,0 pdm3 db "use already loaded image",13,10,0

View File

@ -73,7 +73,7 @@ mode1 db "640x480",0
mode2 db "800x600",0 mode2 db "800x600",0
mode3 db "1024x768",0 mode3 db "1024x768",0
mode4 db "1280x1024",0 mode4 db "1280x1024",0
modes_msg dw mode4-0x10000,mode1-0x10000,mode2-0x10000,mode3-0x10000 modes_msg dw mode4,mode1,mode2,mode3
modevesa20 db " koos LFB",0 modevesa20 db " koos LFB",0
modevesa12 db ", VESA 1.2 Bnk",0 modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 värvi",0 mode9 db "320x200, EGA/CGA 256 värvi",0
@ -85,7 +85,7 @@ on_msg db " sees",13,10,0
off_msg db " väljas",13,10,0 off_msg db " väljas",13,10,0
vrrm_msg db " [c] Kasuta VRR:",0 vrrm_msg db " [c] Kasuta VRR:",0
preboot_device_msg db " [d] Disketi kujutis: ",0 preboot_device_msg db " [d] Disketi kujutis: ",0
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000 preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "reaalne diskett",13,10,0 pdm1 db "reaalne diskett",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "kasuta juba laaditud kujutist",13,10,0 pdm3 db "kasuta juba laaditud kujutist",13,10,0

View File

@ -78,7 +78,7 @@ mode1 db "640x480",0
mode2 db "800x600",0 mode2 db "800x600",0
mode3 db "1024x768",0 mode3 db "1024x768",0
mode4 db "1280x1024",0 mode4 db "1280x1024",0
modes_msg dw mode4-0x10000,mode1-0x10000,mode2-0x10000,mode3-0x10000 modes_msg dw mode4,mode1,mode2,mode3
modevesa20 db " mit LFB",0 modevesa20 db " mit LFB",0
modevesa12 db ", VESA 1.2 Bnk",0 modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 colors",0 mode9 db "320x200, EGA/CGA 256 colors",0
@ -90,7 +90,7 @@ on_msg db " an",13,10,0
off_msg db " aus",13,10,0 off_msg db " aus",13,10,0
vrrm_msg db " [c] Nutze VRR:",0 vrrm_msg db " [c] Nutze VRR:",0
preboot_device_msg db " [d] Diskettenimage: ",0 preboot_device_msg db " [d] Diskettenimage: ",0
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000 preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "Echte Diskette",13,10,0 pdm1 db "Echte Diskette",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "Nutze bereits geladenes Image",13,10,0 pdm3 db "Nutze bereits geladenes Image",13,10,0

View File

@ -17,7 +17,6 @@ novesa db "
vervesa db "‚¥àá¨ï VESA: Vesa x.x",13,10,0 vervesa db "‚¥àá¨ï VESA: Vesa x.x",13,10,0
vervesa_off=19 vervesa_off=19
msg_apm db " APM x.x ", 0 msg_apm db " APM x.x ", 0
gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, " gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, "
db "[3] 1024x768, [4] 1280x1024",13,10 db "[3] 1024x768, [4] 1280x1024",13,10
db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, " db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, "
@ -74,7 +73,7 @@ mode1 db "640x480",0
mode2 db "800x600",0 mode2 db "800x600",0
mode3 db "1024x768",0 mode3 db "1024x768",0
mode4 db "1280x1024",0 mode4 db "1280x1024",0
modes_msg dw mode4-0x10000,mode1-0x10000,mode2-0x10000,mode3-0x10000 modes_msg dw mode4,mode1,mode2,mode3
modevesa20 db " á LFB",0 modevesa20 db " á LFB",0
modevesa12 db ", VESA 1.2 Bnk",0 modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 梥⮢",0 mode9 db "320x200, EGA/CGA 256 梥⮢",0
@ -86,7 +85,7 @@ on_msg db "
off_msg db " ¢ëª«",13,10,0 off_msg db " ¢ëª«",13,10,0
vrrm_msg db " [c] ˆá¯®«ì§®¢ ­¨¥ VRR:",0 vrrm_msg db " [c] ˆá¯®«ì§®¢ ­¨¥ VRR:",0
preboot_device_msg db " [d] Ž¡à § ¤¨áª¥âë: ",0 preboot_device_msg db " [d] Ž¡à § ¤¨áª¥âë: ",0
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000 preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "­ áâ®ïé ï ¤¨áª¥â ",13,10,0 pdm1 db "­ áâ®ïé ï ¤¨áª¥â ",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "¨á¯®«ì§®¢ âì 㦥 § £à㦥­­ë© ®¡à §",13,10,0 pdm3 db "¨á¯®«ì§®¢ âì 㦥 § £à㦥­­ë© ®¡à §",13,10,0

View File

@ -24,7 +24,7 @@ preboot_device db 0 ; boot device
;!!!! 0 - autodetect !!!! ;!!!! 0 - autodetect !!!!
preboot_blogesc db 1 ; start immediately after bootlog preboot_blogesc db 1 ; start immediately after bootlog
if $>10200h if $>0x200
ERROR: prebooting parameters must fit in first sector!!! ERROR: prebooting parameters must fit in first sector!!!
end if end if
hdsysimage db 'KOLIBRI IMG' ; load from hdsysimage db 'KOLIBRI IMG' ; load from

View File

@ -8,7 +8,7 @@ $Revision$
; READ RAMDISK IMAGE FROM HD ; READ RAMDISK IMAGE FROM HD
cmp [boot_dev],1 cmp [boot_dev+OS_BASE+0x10000],1
jne no_sys_on_hd jne no_sys_on_hd
test [DRIVE_DATA+1],byte 0x40 test [DRIVE_DATA+1],byte 0x40
@ -88,7 +88,7 @@ $Revision$
ret ret
read_image: read_image:
mov eax, hdsysimage mov eax, hdsysimage+OS_BASE+0x10000
mov ebx, 1474560/512 mov ebx, 1474560/512
mov ecx, RAMDISK mov ecx, RAMDISK
mov esi, 0 mov esi, 0

View File

@ -90,4 +90,4 @@ RU_FNT2:
db 0x00, 0x00, 0xCF, 0xCD, 0xEF, 0xEC, 0xFF, 0xDC, 0xDC, 0xCC, 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xCF, 0xCD, 0xEF, 0xEC, 0xFF, 0xDC, 0xDC, 0xCC, 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

View File

@ -12,370 +12,249 @@ $Revision$
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
system_shutdown: ; shut down the system
call stop_all_services
push 3 ; stop playing cd
pop eax
call sys_cd_audio
cld
mov al,[0x2f0000+0x9030]
cmp al,1
jl no_shutdown_parameter
cmp al,4
jle yes_shutdown_param
no_shutdown_parameter:
; movzx ecx,word [0x2f0000+0x900A]
; movzx esi,word [0x2f0000+0x900C]
; imul ecx,esi ;[0xfe04]
;; mov ecx,0x500000/4 ;3fff00/4 ; darken screen
; push ecx
; mov esi,[0xfe80]
; cmp esi,32*0x100000
; jbe no_darken_screen
; mov edi,16*0x100000
; push esi edi
; sdnewpix:
; lodsd
; shr eax,1
; and eax,0x7f7f7f7f
; stosd
; loop sdnewpix
; pop ecx
; pop esi edi
; rep movsd
; no_darken_screen:
; read shutdown code:
; 1) display shutdown "window"
mov eax,[0xfe00]
shr eax,1
lea esi,[eax+220] ; x end
sub eax,220 ; x start
mov ebx,[ScreenHeight]
shr ebx,1
mov [shutdownpos],ebx
lea ebp,[ebx+105] ; y end
sub ebx,120 ; y start
xor edi,edi
inc edi ; force putpixel & dtext
mov ecx,0x0000ff
; vertical loop begin
sdnewpix1:
push eax ; save x start
; horizontal loop begin
sdnewpix2:
call [putpixel]
inc eax
cmp eax,esi
jnz sdnewpix2
; horizontal loop end
dec ecx ; color
pop eax ; restore x start
inc ebx ; advance y pos
cmp ebx,ebp
jnz sdnewpix1
; vertical loop end
; 2) display text strings
; a) version
mov eax,[0xfe00]
shr eax,1
shl eax,16
mov ax,word [shutdownpos]
push eax
sub eax,(220-27)*10000h + 105
mov ebx,0xffff00
mov ecx,version
push 34
pop edx
call dtext
; b) variants
add eax,105+33
push 6
pop esi
; mov ebx,0xffffff
mov bl,0xFF
mov ecx,shutdowntext
mov dl,40
newsdt:
call dtext
add eax,10
add ecx,edx
dec esi
jnz newsdt
; 3) load & display rose.txt
mov eax,rosef-std_application_base_address ; load rose.txt
xor ebx,ebx
push 2
pop ecx
mov edx,0x90000
push edx
push 12
pop esi
push edi ; may be destroyed
pushad
push eax
call file_system_lfn ; by SPraid fileread
pop eax
popad
pop edi
pop ecx
inc ecx ; do not display stars from rose.txt
pop eax
add eax,20*10000h - 110
mov ebx,0x00ff00
push 27
pop edx
nrl:
call dtext
; sub ebx,0x050000
ror ebx, 16
sub bl, 0x05
ror ebx, 16
add eax,8
add ecx,31
cmp cx,word 0x0001+25*31
jnz nrl
call checkVga_N13
yes_shutdown_param:
cli
mov eax,kernel ; load kernel.mnt to 0x8000:0
push 12
pop esi
xor ebx,ebx
or ecx,-1
mov edx,0x80000
call fileread
mov esi,restart_kernel_4000+0x10000 ; move kernel re-starter to 0x4000:0
mov edi,0x40000
mov ecx,1000
rep movsb
mov eax,0x2F0000 ; restore 0x0 - 0xffff
xor ebx,ebx
mov ecx,0x10000
call memmove
call restorefatchain
mov al, 0xFF
out 0x21, al
out 0xA1, al
mov word [0x467+0],pr_mode_exit-0x10000
mov word [0x467+2],0x1000
mov al,0x0F
out 0x70,al
mov al,0x05
out 0x71,al
mov al,0xFE
out 0x64,al
hlt
use16
pr_mode_exit: pr_mode_exit:
org $-0x10000
; setup stack ; setup stack
mov ax, 3000h mov ax, 0x3000
mov ss, ax mov ss, ax
mov esp, 0EC00h mov esp, 0x0EC00
; setup ds ; setup ds
push cs push cs
pop ds pop ds
lidt [old_ints_h-0x10000] lidt [old_ints_h]
;remap IRQs ;remap IRQs
mov al,0x11 mov al,0x11
out 0x20,al out 0x20,al
call rdelay call rdelay
out 0xA0,al out 0xA0,al
call rdelay call rdelay
mov al,0x08 mov al,0x08
out 0x21,al out 0x21,al
call rdelay call rdelay
mov al,0x70 mov al,0x70
out 0xA1,al out 0xA1,al
call rdelay call rdelay
mov al,0x04 mov al,0x04
out 0x21,al out 0x21,al
call rdelay call rdelay
mov al,0x02 mov al,0x02
out 0xA1,al out 0xA1,al
call rdelay call rdelay
mov al,0x01 mov al,0x01
out 0x21,al out 0x21,al
call rdelay call rdelay
out 0xA1,al out 0xA1,al
call rdelay call rdelay
mov al,0xB8 mov al,0xB8
out 0x21,al out 0x21,al
call rdelay call rdelay
mov al,0xBD mov al,0xBD
out 0xA1,al out 0xA1,al
sti sti
temp_3456: temp_3456:
xor ax,ax xor ax,ax
mov es,ax mov es,ax
mov al,byte [es:0x9030] mov al,byte [es:0x9030]
cmp al,1 cmp al,1
jl nbw jl nbw
cmp al,4 cmp al,4
jle nbw32 jle nbw32
nbw: nbw:
in al,0x60 in al,0x60
call pause_key call pause_key
cmp al,6 cmp al,6
jae nbw jae nbw
mov bl,al mov bl,al
nbw2: nbw2:
in al,0x60 in al,0x60
call pause_key call pause_key
cmp al,bl cmp al,bl
je nbw2 je nbw2
cmp al,240 ;ax,240 cmp al,240 ;ax,240
jne nbw31 jne nbw31
mov al,bl mov al,bl
dec ax dec ax
jmp nbw32 jmp nbw32
nbw31: nbw31:
add bl,128 add bl,128
cmp al,bl cmp al,bl
jne nbw jne nbw
sub al,129 sub al,129
nbw32: nbw32:
dec ax ; 1 = write floppy dec ax ; 1 = write floppy
js nbw js nbw
jnz no_floppy_write jnz no_floppy_write
call floppy_write call floppy_write
jmp temp_3456 ;nbw jmp temp_3456 ;nbw
no_floppy_write: no_floppy_write:
dec ax ; 2 = power off dec ax ; 2 = power off
jnz no_apm_off jnz no_apm_off
call APM_PowerOff call APM_PowerOff
jmp $ jmp $
no_apm_off: no_apm_off:
dec ax ; 3 = reboot dec ax ; 3 = reboot
jnz restart_kernel ; 4 = restart kernel jnz restart_kernel ; 4 = restart kernel
push 0x40 push 0x40
pop ds pop ds
mov word[0x0072],0x1234 mov word[0x0072],0x1234
jmp 0xF000:0xFFF0 jmp 0xF000:0xFFF0
pause_key: pause_key:
mov cx,100 mov cx,100
pause_key_1: pause_key_1:
loop pause_key_1 loop pause_key_1
ret ret
rdelay: rdelay:
ret ret
iglobal floppy_write: ; write diskette image to physical floppy
kernel db 'KERNEL MNT'
; shutdown_parameter db 0 cmp [flm],byte 1
endg je fwwritedone
mov [flm],byte 1
xor ax, ax ; reset drive
xor dx, dx
int 0x13
mov cx,0x0001 ; startcyl,startsector
xor dx, dx ; starthead,drive
mov ax, 80*2 ; read no of sect
fwwrites:
push ax
; move 1mb+ -> 0:a000
pusha
mov si, fwmovedesc
mov cx,256*18
mov ah,0x87
push ds
pop es
int 0x15
add dword [fwmovedesc+0x12], 512*18
popa
xor si,si
mov es,si
fwnewwrite:
mov bx,0xa000 ; es:bx -> data area
mov ax,0x0300+18 ; read, no of sectors to read
int 0x13
test ah, ah
jz fwgoodwrite
inc si
cmp si,10
jnz fwnewwrite
; can't access diskette - return
pop ax
ret
fwgoodwrite:
inc dh
cmp dh,2
jnz fwbb2
mov dh,0
inc ch
fwbb2:
pop ax
dec ax
jnz fwwrites
ret
APM_PowerOff:
mov ax, 5304h
xor bx, bx
int 15h
;!!!!!!!!!!!!!!!!!!!!!!!!
mov ax,0x5300
xor bx,bx
int 0x15
push ax
mov ax,0x5301
xor bx,bx
int 0x15
mov ax,0x5308
mov bx,1
mov cx,bx
int 0x15
mov ax,0x530E
xor bx,bx
pop cx
int 0x15
mov ax,0x530D
mov bx,1
mov cx,bx
int 0x15
mov ax,0x530F
mov bx,1
mov cx,bx
int 0x15
mov ax,0x5307
mov bx,1
mov cx,3
int 0x15
;!!!!!!!!!!!!!!!!!!!!!!!!
fwwritedone:
ret
restart_kernel: restart_kernel:
mov ax,0x0003 ; set text mode for screen mov ax,0x0003 ; set text mode for screen
int 0x10 int 0x10
jmp 0x4000:0000 jmp 0x4000:0000
restart_kernel_4000: restart_kernel_4000:
cli cli
; mov di,0x1000 ; load kernel image from 0x8000:0 -> 0x1000:0 push ds
; pop es
; new_kernel_block_move: mov cx, 0x8000
; push cx
; mov ebx,0 mov ds, cx
; xor si, si
; new_kernel_byte_move: xor di, di
; rep movsw
; mov ax,di push 0x9000
; add ax,0x7000 pop ds
; mov es,ax push 0x2000
; mov dl,[es:bx] pop es
; mov es,di pop cx
; mov [es:bx],dl rep movsw
;
; inc ebx
; cmp ebx,65536
; jbe new_kernel_byte_move
;
; add di,0x1000
; cmp di,0x2000
; jbe new_kernel_block_move
push ds
pop es
mov cx, 0x8000
push cx
mov ds, cx
xor si, si
xor di, di
rep movsw
push 0x9000
pop ds
push 0x2000
pop es
pop cx
rep movsw
wbinvd ; write and invalidate cache wbinvd ; write and invalidate cache
; mov ax,0x1000 mov al, 00110100b
; mov es,ax out 43h, al
; mov ax,0x3000 jcxz $+2
; mov ss,ax mov al, 0xFF
; mov sp,0xec00 out 40h, al
; restore timer jcxz $+2
mov al, 00110100b out 40h, al
out 43h, al jcxz $+2
jcxz $+2
mov al, 0xFF
out 40h, al
jcxz $+2
out 40h, al
jcxz $+2
sti sti
; (hint by Black_mirror) ; (hint by Black_mirror)
@ -386,160 +265,10 @@ restart_kernel_4000:
in al, 0x60 in al, 0x60
; bootloader interface ; bootloader interface
push 0x1000 push 0x1000
pop ds pop ds
mov si, kernel_restart_bootblock-0x10000 mov si, kernel_restart_bootblock
mov ax, 'KL' mov ax, 'KL'
jmp 0x1000:0000 jmp 0x1000:0000
APM_PowerOff:
mov ax, 5304h
xor bx, bx
int 15h
;!!!!!!!!!!!!!!!!!!!!!!!!
mov ax,0x5300
xor bx,bx
int 0x15
push ax
mov ax,0x5301
xor bx,bx
int 0x15
mov ax,0x5308
mov bx,1
mov cx,bx
int 0x15
mov ax,0x530E
xor bx,bx
pop cx
int 0x15
mov ax,0x530D
mov bx,1
mov cx,bx
int 0x15
mov ax,0x530F
mov bx,1
mov cx,bx
int 0x15
mov ax,0x5307
mov bx,1
mov cx,3
int 0x15
;!!!!!!!!!!!!!!!!!!!!!!!!
fwwritedone:
ret
org $+0x10000
flm db 0
org $-0x10000
floppy_write: ; write diskette image to physical floppy
cmp [flm-0x10000],byte 1
je fwwritedone
mov [flm-0x10000],byte 1
xor ax, ax ; reset drive
xor dx, dx
int 0x13
mov cx,0x0001 ; startcyl,startsector
; mov dx,0x0000 ; starthead,drive
xor dx, dx
mov ax, 80*2 ; read no of sect
fwwrites:
push ax
; move 1mb+ -> 0:a000
pusha
mov si,fwmovedesc -0x10000
mov cx,256*18
mov ah,0x87
push ds
pop es
int 0x15
add dword [fwmovedesc-0x10000+0x12], 512*18
popa
xor si,si
mov es,si
fwnewwrite:
mov bx,0xa000 ; es:bx -> data area
mov ax,0x0300+18 ; read, no of sectors to read
int 0x13
test ah, ah
jz fwgoodwrite
inc si
cmp si,10
jnz fwnewwrite
; can't access diskette - return
pop ax
ret
fwgoodwrite:
inc dh
cmp dh,2
jnz fwbb2
mov dh,0
inc ch
fwbb2:
pop ax
dec ax
jnz fwwrites
ret
org $+0x10000
fwmovedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
org $-0x10000
use32
org $+0x10000
uglobal
shutdownpos dd 0x0
endg
iglobal
if lang eq en
shutdowntext:
db "IT'S SAFE TO POWER OFF COMPUTER OR "
db ' '
db '1) SAVE RAMDISK TO FLOPPY '
db '2) APM - POWEROFF '
db '3) REBOOT '
db '4) RESTART KERNEL '
else if lang eq ru
shutdowntext:
db "<EFBFBD>¥§®¯ á­®¥ ¢ëª«î祭¨¥ ª®¬¯ìîâ¥à  ¨«¨ "
db ' '
db '1) ‘®åà ­¨âì à ¬¤¨áª ­  ¤¨áª¥âã '
db '2) APM - ¢ëª«î祭¨¥ ¯¨â ­¨ï '
db '3) <20>¥à¥§ £à㧪  á¨á⥬ë '
db '4) <20>¥áâ àâ ï¤à  ¨§ Ž‡“ '
else
shutdowntext:
db "SIE KOENNEN DEN COMPUTER NUN AUSSCHALTEN"
db ' '
db '1) RAMDISK AUF DISK SPEICHERN '
db '2) APM - AUSSCHALTEN '
db '3) NEUSTARTEN '
db '4) KERNEL NEU STARTEN '
end if
rosef:
dd 0,0,0,1024,0x90000-std_application_base_address
db '/rd/1/ROSE.TXT',0
endg

View File

@ -1,19 +1,19 @@
$Revision$ $Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; PCI16.INC ;; ;; PCI16.INC ;;
;; ;; ;; ;;
;; 16 bit PCI driver code ;; ;; 16 bit PCI driver code ;;
;; ;; ;; ;;
;; Version 0.2 December 21st, 2002 ;; ;; Version 0.2 December 21st, 2002 ;;
;; ;; ;; ;;
;; Author: Victor Prodan, victorprodan@yahoo.com ;; ;; Author: Victor Prodan, victorprodan@yahoo.com ;;
;; ;; ;; ;;
;; See file COPYING for details ;; ;; See file COPYING for details ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1,23 +1,23 @@
$Revision$ $Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; ;; ;; ;;
;; PCI32.INC ;; ;; PCI32.INC ;;
;; ;; ;; ;;
;; 32 bit PCI driver code ;; ;; 32 bit PCI driver code ;;
;; ;; ;; ;;
;; Version 0.2 December 21st, 2002 ;; ;; Version 0.2 December 21st, 2002 ;;
;; ;; ;; ;;
;; Author: Victor Prodan, victorprodan@yahoo.com ;; ;; Author: Victor Prodan, victorprodan@yahoo.com ;;
;; Credits: ;; ;; Credits: ;;
;; Ralf Brown ;; ;; Ralf Brown ;;
;; Mike Hibbett, mikeh@oceanfree.net ;; ;; Mike Hibbett, mikeh@oceanfree.net ;;
;; ;; ;; ;;
;; See file COPYING for details ;; ;; See file COPYING for details ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -39,7 +39,7 @@ pci_api:
or al,al or al,al
jnz pci_fn_1 jnz pci_fn_1
; PCI function 0: get pci version (AH.AL) ; PCI function 0: get pci version (AH.AL)
movzx eax,word [0x2F0000+0x9022] movzx eax,word [BOOT_VAR+0x9022]
ret ret
pci_fn_1: pci_fn_1:
@ -47,14 +47,14 @@ pci_fn_1:
jnz pci_fn_2 jnz pci_fn_2
; PCI function 1: get last bus in AL ; PCI function 1: get last bus in AL
mov al,[0x2F0000+0x9021] mov al,[BOOT_VAR+0x9021]
ret ret
pci_fn_2: pci_fn_2:
cmp al,2 cmp al,2
jne pci_fn_3 jne pci_fn_3
; PCI function 2: get pci access mechanism ; PCI function 2: get pci access mechanism
mov al,[0x2F0000+0x9020] mov al,[BOOT_VAR+0x9020]
ret ret
pci_fn_3: pci_fn_3:
@ -113,7 +113,7 @@ pci_make_config_cmd:
align 4 align 4
pci_read_reg: pci_read_reg:
cmp byte [0x2F0000+0x9020],2 ;what mechanism will we use? cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use?
je pci_read_reg_2 je pci_read_reg_2
; mechanism 1 ; mechanism 1
@ -243,7 +243,7 @@ pci_read_reg_err:
align 4 align 4
pci_write_reg: pci_write_reg:
cmp byte [0x2F0000+0x9020],2 ;what mechanism will we use? cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use?
je pci_write_reg_2 je pci_write_reg_2
; mechanism 1 ; mechanism 1

View File

@ -12,7 +12,7 @@ cpl0 equ 10011010b ; code read dpl0
cpl3 equ 11111010b ; code read dpl3 cpl3 equ 11111010b ; code read dpl3
D32 equ 01000000b ; 32bit segment D32 equ 01000000b ; 32bit segment
G32 equ 10000000b ; page gran G32 equ 10000000b ; page gran
;;;;;;;;;;;;cpu_caps flags;;;;;;;;;;;;;;;; ;;;;;;;;;;;;cpu_caps flags;;;;;;;;;;;;;;;;
@ -140,13 +140,53 @@ SSE_FZ equ 0x8000
SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM) SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
OS_BASE equ 0
window_data equ (OS_BASE+0x0000000) struc TSS
{
._back rw 2
._esp0 rd 1
._ss0 rw 2
._esp1 rd 1
._ss1 rw 2
._esp2 rd 1
._ss2 rw 2
._cr3 rd 1
._eip rd 1
._eflags rd 1
._eax rd 1
._ecx rd 1
._edx rd 1
._ebx rd 1
._esp rd 1
._ebp rd 1
._esi rd 1
._edi rd 1
._es rw 2
._cs rw 2
._ss rw 2
._ds rw 2
._fs rw 2
._gs rw 2
._ldt rw 2
._trap rw 1
._io rw 1
rb 24
._io_map_0 rb 4096
._io_map_1 rb 4096
}
virtual at 0
TSS TSS
end virtual
TSS_SIZE equ (128+8192)
OS_BASE equ 0x80000000
window_data equ OS_BASE
CURRENT_TASK equ (OS_BASE+0x0003000) CURRENT_TASK equ (OS_BASE+0x0003000)
TASK_COUNT equ (OS_BASE+0x0003004) TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_RING0_ESP equ (OS_BASE+0x0003008)
TASK_BASE equ (OS_BASE+0x0003010) TASK_BASE equ (OS_BASE+0x0003010)
TASK_DATA equ (OS_BASE+0x0003020) TASK_DATA equ (OS_BASE+0x0003020)
TASK_EVENT equ (OS_BASE+0x0003020) TASK_EVENT equ (OS_BASE+0x0003020)
@ -203,7 +243,6 @@ MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF)
LFBAddress equ (OS_BASE+0x000FE80) LFBAddress equ (OS_BASE+0x000FE80)
MEM_AMOUNT equ (OS_BASE+0x000FE8C) MEM_AMOUNT equ (OS_BASE+0x000FE8C)
;LFBSize equ (OS_BASE+0x02f9050)
ScreenWidth equ (OS_BASE+0x000FE00) ScreenWidth equ (OS_BASE+0x000FE00)
ScreenHeight equ (OS_BASE+0x000FE04) ScreenHeight equ (OS_BASE+0x000FE04)
@ -247,7 +286,6 @@ IMG_BACKGROUND equ (OS_BASE+0x0300000)
WinMapAddress equ (OS_BASE+0x0460000) WinMapAddress equ (OS_BASE+0x0460000)
display_data equ (OS_BASE+0x0460000) display_data equ (OS_BASE+0x0460000)
;unused ?
HD_CACHE equ (OS_BASE+0x0600000) HD_CACHE equ (OS_BASE+0x0600000)
stack_data_start equ (OS_BASE+0x0700000) stack_data_start equ (OS_BASE+0x0700000)
@ -259,32 +297,68 @@ resendQ equ (OS_BASE+0x0770000)
skin_data equ (OS_BASE+0x0778000) skin_data equ (OS_BASE+0x0778000)
draw_data equ (OS_BASE+0x0780000);
tss_data equ (OS_BASE+0x780000) virtual at (OS_BASE+0x0783F80)
draw_data equ (OS_BASE+0x988000) tss TSS
end virtual
HEAP_BASE equ (OS_BASE+0x98B000) tmp_page_tab equ 0x0786000;
LFB_BASE equ 0x7DC00000 HEAP_BASE equ (OS_BASE+tmp_page_tab)
HEAP_MIN_SIZE equ 0x01000000
page_tabs equ 0x7FC00000 page_tabs equ 0xFDC00000
master_tab equ 0x7FDFF000 app_page_tabs equ 0xFDC00000
app_page_tabs equ 0x7FE00000 kernel_tabs equ (page_tabs+ (OS_BASE shr 10)) ;0xFDE00000
master_tab equ (page_tabs+ (page_tabs shr 10)) ;0xFDFF70000
sys_pgdir equ OS_BASE+0x00050000 LFB_BASE equ 0xFE000000
sys_master_tab equ OS_BASE+0x00051000
sys_pgmap equ OS_BASE+0x00052000 sys_pgdir equ (OS_BASE+0x00050000)
sys_pgmap equ (OS_BASE+0x00052000)
new_app_base equ 0;
new_app_base equ 0x80000000 twdw equ 0x3000 ;(CURRENT_TASK-window_data)
twdw equ (CURRENT_TASK-window_data)
std_application_base_address equ new_app_base std_application_base_address equ new_app_base
RING0_STACK_SIZE equ (0x2000-512) ;512 áàéò äëÿ êîíòåêñòà FPU RING0_STACK_SIZE equ (0x2000 - 512) ;512 áàéò äëÿ êîíòåêñòà FPU
if 0
REG_SS equ (RING0_STACK_SIZE-4)
REG_APP_ESP equ (RING0_STACK_SIZE-8)
REG_EFLAGS equ (RING0_STACK_SIZE-12)
REG_CS equ (RING0_STACK_SIZE-16)
REG_EIP equ (RING0_STACK_SIZE-20)
REG_EFL_2 equ (RING0_STACK_SIZE-24)
REG_EAX equ (RING0_STACK_SIZE-28)
REG_ECX equ (RING0_STACK_SIZE-32)
REG_EDX equ (RING0_STACK_SIZE-36)
REG_EBX equ (RING0_STACK_SIZE-40)
REG_ESP equ (RING0_STACK_SIZE-44) ;RING0_STACK_SIZE-20
REG_EBP equ (RING0_STACK_SIZE-48)
REG_ESI equ (RING0_STACK_SIZE-52)
REG_EDI equ (RING0_STACK_SIZE-56)
REG_RET equ (RING0_STACK_SIZE-60) ;irq0.return
end if
REG_SS equ (RING0_STACK_SIZE-4)
REG_APP_ESP equ (RING0_STACK_SIZE-8)
REG_EFLAGS equ (RING0_STACK_SIZE-12)
REG_CS equ (RING0_STACK_SIZE-16)
REG_EIP equ (RING0_STACK_SIZE-20)
REG_EAX equ (RING0_STACK_SIZE-24)
REG_ECX equ (RING0_STACK_SIZE-28)
REG_EDX equ (RING0_STACK_SIZE-32)
REG_EBX equ (RING0_STACK_SIZE-36)
REG_ESP equ (RING0_STACK_SIZE-40) ;RING0_STACK_SIZE-20
REG_EBP equ (RING0_STACK_SIZE-44)
REG_ESI equ (RING0_STACK_SIZE-48)
REG_EDI equ (RING0_STACK_SIZE-52)
REG_RET equ (RING0_STACK_SIZE-56) ;irq0.return
;PAGES_USED equ 4
PG_UNMAP equ 0x000 PG_UNMAP equ 0x000
PG_MAP equ 0x001 PG_MAP equ 0x001
@ -331,16 +405,27 @@ EVENT_EXTENDED equ 0x00000200
EV_INTR equ 1 EV_INTR equ 1
struc THR_DATA
{
rb (8192-512)
.pl0_stack:
.fpu_state rb 512
.tls_page rb 4096
.pdbr rb 4096
}
THR_DATA_SIZE equ 4096*4
virtual at (OS_BASE-THR_DATA_SIZE)
thr_data THR_DATA
end virtual
struc SYS_VARS struc SYS_VARS
{ .bpp dd ? { .bpp dd ?
.scanline dd ? .scanline dd ?
.vesa_mode dd ? .vesa_mode dd ?
.x_res dd ? .x_res dd ?
.y_res dd ? .y_res dd ?
.cpu_caps dd ?
dd ?
dd ?
dd ?
} }
struc APPOBJ ;common object header struc APPOBJ ;common object header
@ -467,7 +552,6 @@ struc PG_DATA
.pages_free dd ? .pages_free dd ?
.pages_faults dd ? .pages_faults dd ?
.pagemap_size dd ? .pagemap_size dd ?
.kernel_max dd ?
.kernel_pages dd ? .kernel_pages dd ?
.kernel_tables dd ? .kernel_tables dd ?
.sys_page_dir dd ? .sys_page_dir dd ?
@ -496,6 +580,9 @@ struc SRV
SRV_FD_OFFSET equ 0x18 SRV_FD_OFFSET equ 0x18
SRV_SIZE equ 44 SRV_SIZE equ 44
DRV_ENTRY equ 1
DRV_EXIT equ -1
struc COFF_HEADER struc COFF_HEADER
{ .machine dw ? { .machine dw ?
.nSections dw ? .nSections dw ?

View File

@ -27,9 +27,8 @@ sys_debug_services_table:
debug_set_event_data: debug_set_event_data:
; in: ebx = pointer ; in: ebx = pointer
; destroys eax ; destroys eax
mov eax, [CURRENT_TASK] mov eax, [current_slot]
shl eax, 8 mov [eax+APPDATA.dbg_event_mem], ebx
mov [eax+SLOT_BASE+APPDATA.dbg_event_mem], ebx
ret ret
get_debuggee_slot: get_debuggee_slot:
@ -123,7 +122,6 @@ debug_getcontext:
; destroys eax,ecx,edx,esi,edi ; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h cmp ecx, 28h
jnz .ret jnz .ret
add edx, std_application_base_address
push ebx push ebx
mov ebx, edx mov ebx, edx
call check_region call check_region
@ -132,43 +130,35 @@ debug_getcontext:
jnz .ret jnz .ret
call get_debuggee_slot call get_debuggee_slot
jc .ret jc .ret
imul eax, tss_step/32 mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
add eax, tss_data lea esi, [eax+RING0_STACK_SIZE]
mov edi, edx mov edi, edx
cmp [eax+TSS._cs], app_code
jnz .ring0
lea esi, [eax+TSS._eip]
shr ecx, 2
rep movsd
jmp .ret
.ring0: .ring0:
; note that following code assumes that all interrupt/exception handlers ; note that following code assumes that all interrupt/exception handlers
; saves ring-3 context by push ds es, pushad in this order ; saves ring-3 context by pushad in this order
mov esi, [eax+TSS._esp0] ; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), ds, es, pushad sub esi, 8+12+20h
sub esi, 8+12+8+20h lodsd ;edi
lodsd
mov [edi+24h], eax mov [edi+24h], eax
lodsd lodsd ;esi
mov [edi+20h], eax mov [edi+20h], eax
lodsd lodsd ; ebp
mov [edi+1Ch], eax mov [edi+1Ch], eax
lodsd lodsd ;esp
lodsd lodsd ;ebx
mov [edi+14h], eax mov [edi+14h], eax
lodsd lodsd ;edx
mov [edi+10h], eax mov [edi+10h], eax
lodsd lodsd ;ecx
mov [edi+0Ch], eax mov [edi+0Ch], eax
lodsd lodsd ;eax
mov [edi+8], eax mov [edi+8], eax
add esi, 8 lodsd ;eip
lodsd
mov [edi], eax mov [edi], eax
lodsd lodsd ;cs
lodsd lodsd ;eflags
mov [edi+4], eax mov [edi+4], eax
lodsd lodsd ;esp
mov [edi+18h], eax mov [edi+18h], eax
.ret: .ret:
sti sti
@ -182,7 +172,6 @@ debug_setcontext:
; destroys eax,ecx,edx,esi,edi ; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h cmp ecx, 28h
jnz .ret jnz .ret
add edx, std_application_base_address
push ebx push ebx
mov ebx, edx mov ebx, edx
call check_region call check_region
@ -191,40 +180,32 @@ debug_setcontext:
jnz .ret jnz .ret
call get_debuggee_slot call get_debuggee_slot
jc .stiret jc .stiret
imul eax, tss_step/32 mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
add eax, tss_data lea edi, [eax+RING0_STACK_SIZE]
mov esi, edx mov esi, edx
cmp [eax+TSS._cs], app_code
jnz .ring0
lea edi, [eax+TSS._eip]
shr ecx, 2
rep movsd
jmp .stiret
.ring0: .ring0:
mov edi, [eax+TSS._esp0] sub edi, 8+12+20h
sub edi, 8+12+8+20h mov eax, [esi+24h] ;edi
mov eax, [esi+24h]
stosd stosd
mov eax, [esi+20h] mov eax, [esi+20h] ;esi
stosd stosd
mov eax, [esi+1Ch] mov eax, [esi+1Ch] ;ebp
stosd
scasd
mov eax, [esi+14h] ;ebx
stosd
mov eax, [esi+10h] ;edx
stosd
mov eax, [esi+0Ch] ;ecx
stosd
mov eax, [esi+8] ;eax
stosd
mov eax, [esi] ;eip
stosd stosd
scasd scasd
mov eax, [esi+14h] mov eax, [esi+4] ;eflags
stosd stosd
mov eax, [esi+10h] mov eax, [esi+18h] ;esp
stosd
mov eax, [esi+0Ch]
stosd
mov eax, [esi+8]
stosd
add edi, 8
mov eax, [esi]
stosd
scasd
mov eax, [esi+4]
stosd
mov eax, [esi+18h]
stosd stosd
.stiret: .stiret:
sti sti
@ -238,8 +219,8 @@ debug_set_drx:
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs] lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs]
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3 ; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
; [eax+10]=dr7 ; [eax+10]=dr7
add edx, std_application_base_address cmp edx, OS_BASE
jc .errret jae .errret
cmp cl, 3 cmp cl, 3
ja .errret ja .errret
mov ebx, dr7 mov ebx, dr7
@ -256,8 +237,9 @@ debug_set_drx:
btr dword [eax+10h], ecx ; clear L<i> bit btr dword [eax+10h], ecx ; clear L<i> bit
test byte [eax+10h], 55h test byte [eax+10h], 55h
jnz .okret jnz .okret
imul eax, ebp, tss_step/32 ; imul eax, ebp, tss_step/32
and byte [eax + tss_data + TSS._trap], not 1 ; and byte [eax + tss_data + TSS._trap], not 1
and [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1
.okret: .okret:
and dword [esp+36], 0 and dword [esp+36], 0
sti sti
@ -298,8 +280,9 @@ debug_set_drx:
not edx not edx
and [eax+10h+2], dx and [eax+10h+2], dx
or [eax+10h+2], bx ; set R/W and LEN fields or [eax+10h+2], bx ; set R/W and LEN fields
imul eax, ebp, tss_step/32 ; imul eax, ebp, tss_step/32
or byte [eax + tss_data + TSS._trap], 1 ; or byte [eax + tss_data + TSS._trap], 1
or [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1
jmp .okret jmp .okret
debug_read_process_memory: debug_read_process_memory:
@ -310,7 +293,6 @@ debug_read_process_memory:
; edx=address in debuggee ; edx=address in debuggee
; out: [esp+36]=sizeof(read) ; out: [esp+36]=sizeof(read)
; destroys all ; destroys all
add esi, std_application_base_address
push ebx push ebx
mov ebx, esi mov ebx, esi
call check_region call check_region
@ -337,7 +319,6 @@ debug_write_process_memory:
; edx=address in debuggee ; edx=address in debuggee
; out: [esp+36]=sizeof(write) ; out: [esp+36]=sizeof(write)
; destroys all ; destroys all
add esi, std_application_base_address
push ebx push ebx
mov ebx, esi mov ebx, esi
call check_region call check_region
@ -430,45 +411,22 @@ debug_exc:
; int 1 = #DB ; int 1 = #DB
save_ring3_context save_ring3_context
cld cld
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
mov eax, dr6 mov eax, dr6
test ax, ax
jns @f
; this is exception from task switch
; set DRx registers for task and continue
mov eax, [CURRENT_TASK]
shl eax, 8
add eax, SLOT_BASE+APPDATA.dbg_regs
mov ecx, [eax+0]
mov dr0, ecx
mov ecx, [eax+4]
mov dr1, ecx
mov ecx, [eax+8]
mov dr2, ecx
mov ecx, [eax+0Ch]
mov dr3, ecx
xor ecx, ecx
mov dr6, ecx
mov ecx, [eax+10h]
mov dr7, ecx
restore_ring3_context
iretd
@@:
push eax push eax
xor eax, eax xor eax, eax
mov dr6, eax mov dr6, eax
; test if debugging ; test if debugging
cli cli
mov eax, [CURRENT_TASK] mov eax, [current_slot]
shl eax, 8 mov eax, [eax+APPDATA.debugger_slot]
mov eax, [SLOT_BASE+eax+APPDATA.debugger_slot]
test eax, eax test eax, eax
jnz .debug jnz .debug
sti sti
; not debuggee => say error and terminate ; not debuggee => say error and terminate
add esp, 28h+4 add esp, 0x20+4
mov [error_interrupt], 1 mov [error_interrupt], 1
call show_error_parameters call show_error_parameters
mov edx, [TASK_BASE] mov edx, [TASK_BASE]

View File

@ -6,10 +6,8 @@ $Revision$
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DRV_ENTRY equ 1 DRV_COMPAT equ 5 ;minimal required drivers version
DRV_EXIT equ -1 DRV_CURRENT equ 5 ;current drivers model version
DRV_COMPAT equ 4 ;minimal required drivers version
DRV_CURRENT equ 4 ;current drivers model version
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
@ -134,7 +132,7 @@ align 4
align 16 align 16
.main: .main:
save_ring3_context save_ring3_context
mov bx, os_data mov bx, app_data ;os_data
mov ds, bx mov ds, bx
mov es, bx mov es, bx
@ -161,14 +159,13 @@ align 4
proc get_notify stdcall, p_ev:dword proc get_notify stdcall, p_ev:dword
.wait: .wait:
mov ebx,[CURRENT_TASK] mov ebx,[current_slot]
shl ebx,8 test dword [ebx+APPDATA.event_mask],EVENT_NOTIFY
test dword [ebx+SLOT_BASE+0xA8],EVENT_NOTIFY
jz @f jz @f
and dword [ebx+SLOT_BASE+0xA8], not EVENT_NOTIFY and dword [ebx+APPDATA.event_mask], not EVENT_NOTIFY
mov edi, [p_ev] mov edi, [p_ev]
mov dword [edi], EV_INTR mov dword [edi], EV_INTR
mov eax, [ebx+SLOT_BASE+APPDATA.event] mov eax, [ebx+APPDATA.event]
mov dword [edi+4], eax mov dword [edi+4], eax
ret ret
@@: @@:
@ -256,9 +253,8 @@ endp
align 4 align 4
srv_handlerEx: srv_handlerEx:
test ebx, ebx cmp ebx, OS_BASE
jz .fail jae .fail
add ebx, new_app_base
mov eax, [ebx+handle] mov eax, [ebx+handle]
cmp [eax+SRV.magic], ' SRV' cmp [eax+SRV.magic], ' SRV'
@ -267,9 +263,6 @@ srv_handlerEx:
cmp [eax+SRV.size], SRV_SIZE cmp [eax+SRV.size], SRV_SIZE
jne .fail jne .fail
add [ebx+input], new_app_base
add [ebx+output], new_app_base
stdcall [eax+SRV.srv_proc], ebx stdcall [eax+SRV.srv_proc], ebx
ret ret
.fail: .fail:
@ -410,9 +403,9 @@ proc get_fileinfo stdcall, file_name:dword, info:dword
xor eax, eax xor eax, eax
mov ebx, [file_name] mov ebx, [file_name]
sub ebx, new_app_base ; sub ebx, new_app_base
mov ecx, [info] mov ecx, [info]
sub ecx, new_app_base ; sub ecx, new_app_base
mov [cmd], 5 mov [cmd], 5
mov [offset], eax mov [offset], eax
@ -424,7 +417,7 @@ proc get_fileinfo stdcall, file_name:dword, info:dword
mov eax, 70 mov eax, 70
lea ebx, [cmd] lea ebx, [cmd]
sub ebx, new_app_base ; sub ebx, new_app_base
int 0x40 int 0x40
ret ret
endp endp
@ -447,8 +440,6 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\
mov ecx, [off] mov ecx, [off]
mov edx, [bytes] mov edx, [bytes]
mov esi, [buffer] mov esi, [buffer]
sub ebx, new_app_base
sub esi, new_app_base
mov [cmd], eax mov [cmd], eax
mov [offset], ecx mov [offset], ecx
@ -461,7 +452,6 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\
pushad pushad
push eax push eax
lea eax, [cmd] lea eax, [cmd]
sub eax, new_app_base
call file_system_lfn call file_system_lfn
pop eax pop eax
popad popad
@ -708,23 +698,23 @@ proc load_driver stdcall, driver_name:dword
file_name rb 14+16+4+1 ; '/rd/1/drivers/<up-to-16-chars>.obj' file_name rb 14+16+4+1 ; '/rd/1/drivers/<up-to-16-chars>.obj'
endl endl
lea edx, [file_name] lea edx, [file_name]
mov dword [edx], '/rd/' mov dword [edx], '/rd/'
mov dword [edx+4], '1/dr' mov dword [edx+4], '1/dr'
mov dword [edx+8], 'iver' mov dword [edx+8], 'iver'
mov word [edx+12], 's/' mov word [edx+12], 's/'
mov esi, [driver_name] mov esi, [driver_name]
lea edi, [edx+14] lea edi, [edx+14]
mov ecx, 16 mov ecx, 16
@@: @@:
lodsb lodsb
test al, al test al, al
jz @f jz @f
stosb stosb
loop @b loop @b
@@: @@:
mov dword [edi], '.obj' mov dword [edi], '.obj'
mov byte [edi+4], 0 mov byte [edi+4], 0
stdcall load_file, edx stdcall load_file, edx
test eax, eax test eax, eax
@ -919,13 +909,13 @@ proc load_library stdcall, file_name:dword
jmp .next jmp .next
.copy: .copy:
add esi, edx add esi, edx
add edi, new_app_base ; add edi, new_app_base
mov ecx, [eax+CFS.SizeOfRawData] mov ecx, [eax+CFS.SizeOfRawData]
cld cld
rep movsb rep movsb
.next: .next:
add edi, 15-new_app_base add edi, 15 ;-new_app_base
and edi, not 15 and edi, -16
add eax, COFF_SECTION_SIZE add eax, COFF_SECTION_SIZE
dec ebx dec ebx
jnz @B jnz @B
@ -1006,9 +996,8 @@ create_kernel_object:
test eax, eax test eax, eax
jz .fail jz .fail
mov ecx,[CURRENT_TASK] mov ecx,[current_slot]
shl ecx,8 add ecx, APP_OBJ_OFFSET
add ecx, SLOT_BASE+APP_OBJ_OFFSET
pushfd pushfd
cli cli
@ -1048,21 +1037,68 @@ destroy_kernel_object:
ret ret
;szSound db 'SOUND',0
;szInfinity db 'INFINITY',0
szHwMouse db 'ATI2D',0
szSTART db 'START',0 if 0
szEXPORTS db 'EXPORTS',0
szIMPORTS db 'IMPORTS',0 irq:
.irq0:
pusfd
pushad
push IRQ_0
jmp .master
.irq_1:
pusfd
pushad
push IRQ_1
jmp .master
.master:
mov ax, app_data
mov ds, eax
mov es, eax
mov ebx, [esp+4] ;IRQ_xx
mov eax, [irq_handlers+ebx+4]
call intr_handler
mov ecx, [esp+4]
cmp [irq_actids+ecx*4], 0
je @F
in al, 0x21
bts eax, ecx
out 0x21, al
mov al, 0x20
out 0x20, al
jmp .restart
.slave:
mov ax, app_data
mov ds, eax
mov es, eax
mov ebx, [esp+4] ;IRQ_xx
mov eax, [irq_handlers+ebx+4]
call intr_handler
mov ecx, [esp+4]
sub ecx, 8
cmp [irq_actids+ecx*4], 0
je @F
in al, 0xA1
bts eax, ecx
out 0xA1, al
mov al, 0x20
out 0xA0, al
out 0x20, al
.restart:
mov ebx, [next_slot]
test ebx, ebx
jz @F
mov [next_task],0
mov esi, [prev_slot]
call do_change_task
add esp, 4
iretd
end if
msg_unresolved db 'unresolved ',0
msg_module db 'in module ',0
msg_version db 'incompatible driver version',13,10,0
msg_www db 'please visit www.kolibrios.org',13,10,0
msg_CR db 13,10,0
align 4
create_cursor dd 0
set_hw_cursor dd 0
hw_restore dd 0

View File

@ -141,40 +141,40 @@ fpu_restore:
align 4 align 4
e7: ;#NM exception handler e7: ;#NM exception handler
save_ring3_context save_ring3_context
clts clts
mov ax, os_data mov ax, app_data ;
mov ds, ax mov ds, ax
mov es, ax mov es, ax
mov ebx, [fpu_owner] mov ebx, [fpu_owner]
cmp ebx, [CURRENT_TASK] cmp ebx, [CURRENT_TASK]
je .exit je .exit
shl ebx, 8 shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state] mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
bt [cpu_caps], CAPS_SSE bt [cpu_caps], CAPS_SSE
jnc .no_SSE jnc .no_SSE
fxsave [eax] fxsave [eax]
mov ebx, [CURRENT_TASK] mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx mov [fpu_owner], ebx
shl ebx, 8 shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state] mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
fxrstor [eax] fxrstor [eax]
.exit: .exit:
restore_ring3_context restore_ring3_context
iret iret
.no_SSE: .no_SSE:
fnsave [eax] fnsave [eax]
mov ebx, [CURRENT_TASK] mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx mov [fpu_owner], ebx
shl ebx, 8 shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state] mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
frstor [eax] frstor [eax]
restore_ring3_context restore_ring3_context
iret iret
iglobal iglobal
fpu_owner dd 1 fpu_owner dd 1
@ -196,17 +196,17 @@ except_16: ;fpu native exceptions handler
push ecx push ecx
push edx push edx
mov ebx, [ss:CURRENT_TASK] mov ebx, [CURRENT_TASK]
shl ebx, 8 shl ebx, 8
mov eax, [ss:ebx+SLOT_BASE+APPDATA.fpu_handler] mov eax, [ebx+SLOT_BASE+APPDATA.fpu_handler]
test eax, eax test eax, eax
jz .default jz .default
mov ecx, [reg_eip] mov ecx, [reg_eip]
mov edx, [reg_esp] mov edx, [reg_esp]
sub edx, 4 sub edx, 4
mov [ss:edx+new_app_base], ecx mov [edx], ecx
mov [reg_esp], edx mov [reg_esp], edx
mov dword [reg_eip], eax mov dword [reg_eip], eax
@ -240,17 +240,16 @@ except_19: ;sse exceptions handler
push ecx push ecx
push edx push edx
mov ebx, [ss:CURRENT_TASK] mov ebx, [current_slot]
shl ebx, 8
mov eax, [ss:ebx+SLOT_BASE+APPDATA.sse_handler] mov eax, [ebx+APPDATA.sse_handler]
test eax, eax test eax, eax
jz .default jz .default
mov ecx, [reg_eip] mov ecx, [reg_eip]
mov edx, [reg_esp] mov edx, [reg_esp]
sub edx, 4 sub edx, 4
mov [ss:edx+new_app_base], ecx mov [edx], ecx
mov [reg_esp], edx mov [reg_esp], edx
mov dword [reg_eip], eax mov dword [reg_eip], eax

View File

@ -621,25 +621,24 @@ HEAP_TOP equ 0x5FC00000
align 4 align 4
proc init_heap proc init_heap
mov ebx,[CURRENT_TASK] mov ebx,[current_slot]
shl ebx,8 mov eax, [ebx+APPDATA.heap_top]
mov eax, [SLOT_BASE+APPDATA.heap_top+ebx]
test eax, eax test eax, eax
jz @F jz @F
sub eax,[SLOT_BASE+APPDATA.heap_base+ebx] sub eax,[ebx+APPDATA.heap_base]
sub eax, 4096 sub eax, 4096
ret ret
@@: @@:
mov esi, [SLOT_BASE+APPDATA.mem_size+ebx] mov esi, [ebx+APPDATA.mem_size]
add esi, 4095 add esi, 4095
and esi, not 4095 and esi, not 4095
mov [SLOT_BASE+APPDATA.mem_size+ebx], esi mov [ebx+APPDATA.mem_size], esi
mov eax, HEAP_TOP mov eax, HEAP_TOP
mov [SLOT_BASE+APPDATA.heap_base+ebx], esi mov [ebx+APPDATA.heap_base], esi
mov [SLOT_BASE+APPDATA.heap_top+ebx], eax mov [ebx+APPDATA.heap_top], eax
sub eax, esi sub eax, esi
add esi, new_app_base ; add esi, new_app_base
shr esi, 10 shr esi, 10
mov ecx, eax mov ecx, eax
sub eax, 4096 sub eax, 4096
@ -658,12 +657,9 @@ proc user_alloc stdcall, alloc_size:dword
add ecx, (4095+4096) add ecx, (4095+4096)
and ecx, not 4095 and ecx, not 4095
mov ebx, [CURRENT_TASK] mov ebx, [current_slot]
shl ebx, 8 mov esi, dword [ebx+APPDATA.heap_base] ; heap_base
mov esi, dword [ebx+SLOT_BASE+APPDATA.heap_base]; heap_base mov edi, dword [ebx+APPDATA.heap_top] ; heap_top
mov edi, dword [ebx+SLOT_BASE+APPDATA.heap_top]; heap_top
add esi, new_app_base
add edi, new_app_base
l_0: l_0:
cmp esi, edi cmp esi, edi
jae m_exit jae m_exit
@ -684,7 +680,6 @@ l_0:
or eax, FREE_BLOCK or eax, FREE_BLOCK
shr edx, 12 shr edx, 12
mov [page_tabs+edx*4], eax mov [page_tabs+edx*4], eax
@@: @@:
or ecx, USED_BLOCK or ecx, USED_BLOCK
mov [page_tabs+ebx*4], ecx mov [page_tabs+ebx*4], ecx
@ -697,17 +692,15 @@ l_0:
dec ecx dec ecx
jnz @B jnz @B
mov edx, [CURRENT_TASK] mov edx, [current_slot]
shl edx, 8 mov ebx, [alloc_size]
mov ebx, [alloc_size] add ebx, 0xFFF
add ebx, 0xFFF and ebx, not 0xFFF
and ebx, not 0xFFF add ebx, [edx+APPDATA.mem_size]
add ebx, [SLOT_BASE+APPDATA.mem_size+edx] call update_mem_size
call update_mem_size
mov eax, esi mov eax, esi
add eax, 4096 add eax, 4096
sub eax, new_app_base
ret ret
m_next: m_next:
add esi, eax add esi, eax
@ -760,11 +753,10 @@ proc user_free stdcall, base:dword
dec ecx dec ecx
jnz .release jnz .release
.not_used: .not_used:
mov edx, [CURRENT_TASK] mov edx, [current_slot]
shl edx, 8 mov esi, dword [edx+APPDATA.heap_base]
mov esi, dword [edx+SLOT_BASE+APPDATA.heap_base]; heap_base mov edi, dword [edx+APPDATA.heap_top]
mov edi, dword [edx+SLOT_BASE+APPDATA.heap_top]; heap_top sub ebx, [edx+APPDATA.mem_size]
sub ebx, [edx+SLOT_BASE+APPDATA.mem_size]
neg ebx neg ebx
call update_mem_size call update_mem_size
call user_normalize call user_normalize
@ -779,8 +771,6 @@ user_normalize:
; in: esi=heap_base, edi=heap_top ; in: esi=heap_base, edi=heap_top
; out: eax=0 <=> OK ; out: eax=0 <=> OK
; destroys: ebx,edx,esi,edi ; destroys: ebx,edx,esi,edi
add esi, new_app_base
add edi, new_app_base
shr esi, 12 shr esi, 12
shr edi, 12 shr edi, 12
@@: @@:
@ -835,7 +825,7 @@ user_realloc:
ret ret
@@: @@:
push ecx edx push ecx edx
lea ecx, [eax + new_app_base - 0x1000] lea ecx, [eax - 0x1000]
shr ecx, 12 shr ecx, 12
mov edx, [page_tabs+ecx*4] mov edx, [page_tabs+ecx*4]
test edx, USED_BLOCK test edx, USED_BLOCK
@ -874,16 +864,15 @@ user_realloc:
jnz .nofreeall jnz .nofreeall
mov eax, [page_tabs+ecx*4] mov eax, [page_tabs+ecx*4]
and eax, not 0xFFF and eax, not 0xFFF
mov edx, [CURRENT_TASK] mov edx, [current_slot]
shl edx, 8 mov ebx, [APPDATA.mem_size+edx]
mov ebx, [SLOT_BASE+APPDATA.mem_size+edx]
sub ebx, eax sub ebx, eax
add ebx, 0x1000 add ebx, 0x1000
or al, FREE_BLOCK or al, FREE_BLOCK
mov [page_tabs+ecx*4], eax mov [page_tabs+ecx*4], eax
push esi edi push esi edi
mov esi, [SLOT_BASE+APPDATA.heap_base+edx] mov esi, [APPDATA.heap_base+edx]
mov edi, [SLOT_BASE+APPDATA.heap_top+edx] mov edi, [APPDATA.heap_top+edx]
call update_mem_size call update_mem_size
call user_normalize call user_normalize
pop edi esi pop edi esi
@ -896,14 +885,13 @@ user_realloc:
shr ebx, 12 shr ebx, 12
sub ebx, edx sub ebx, edx
push ebx ecx edx push ebx ecx edx
mov edx, [CURRENT_TASK] mov edx, [current_slot]
shl edx, 8
shl ebx, 12 shl ebx, 12
sub ebx, [SLOT_BASE+APPDATA.mem_size+edx] sub ebx, [APPDATA.mem_size+edx]
neg ebx neg ebx
call update_mem_size call update_mem_size
pop edx ecx ebx pop edx ecx ebx
lea eax, [ecx+1-(new_app_base shr 12)] lea eax, [ecx+1]
shl eax, 12 shl eax, 12
push eax push eax
add ecx, ebx add ecx, ebx
@ -911,9 +899,8 @@ user_realloc:
shl ebx, 12 shl ebx, 12
jz .ret jz .ret
push esi push esi
mov esi, [CURRENT_TASK] mov esi, [current_slot]
shl esi, 8 mov esi, [APPDATA.heap_top+esi]
mov esi, [SLOT_BASE+APPDATA.heap_top+esi]
shr esi, 12 shr esi, 12
@@: @@:
cmp edx, esi cmp edx, esi
@ -935,10 +922,8 @@ user_realloc:
ret ret
.realloc_add: .realloc_add:
; get some additional memory ; get some additional memory
mov eax, [CURRENT_TASK] mov eax, [current_slot]
shl eax, 8 mov eax, [APPDATA.heap_top+eax]
mov eax, [SLOT_BASE+APPDATA.heap_top+eax]
add eax, new_app_base
shr eax, 12 shr eax, 12
cmp edx, eax cmp edx, eax
jae .cant_inplace jae .cant_inplace
@ -958,7 +943,7 @@ user_realloc:
shl eax, 12 shl eax, 12
or al, USED_BLOCK or al, USED_BLOCK
mov [page_tabs+ecx*4], eax mov [page_tabs+ecx*4], eax
lea eax, [ecx+1-(new_app_base shr 12)] lea eax, [ecx+1]
shl eax, 12 shl eax, 12
push eax push eax
push edi push edi
@ -969,21 +954,17 @@ user_realloc:
cld cld
rep stosd rep stosd
pop edi pop edi
mov edx, [CURRENT_TASK] mov edx, [current_slot]
shl edx, 8
shl ebx, 12 shl ebx, 12
add ebx, [SLOT_BASE+APPDATA.mem_size+edx] add ebx, [APPDATA.mem_size+edx]
call update_mem_size call update_mem_size
pop eax edx ecx pop eax edx ecx
ret ret
.cant_inplace: .cant_inplace:
push esi edi push esi edi
mov eax, [CURRENT_TASK] mov eax, [current_slot]
shl eax, 8 mov esi, [APPDATA.heap_base+eax]
mov esi, [SLOT_BASE+APPDATA.heap_base+eax] mov edi, [APPDATA.heap_top+eax]
mov edi, [SLOT_BASE+APPDATA.heap_top+eax]
add esi, new_app_base
add edi, new_app_base
shr esi, 12 shr esi, 12
shr edi, 12 shr edi, 12
sub ebx, ecx sub ebx, ecx
@ -1022,7 +1003,6 @@ user_realloc:
inc esi inc esi
mov eax, esi mov eax, esi
shl eax, 12 shl eax, 12
sub eax, new_app_base
push eax push eax
mov eax, [page_tabs+ecx*4] mov eax, [page_tabs+ecx*4]
and eax, not 0xFFF and eax, not 0xFFF
@ -1043,10 +1023,9 @@ user_realloc:
dec edx dec edx
jnz @b jnz @b
push ebx push ebx
mov edx, [CURRENT_TASK] mov edx, [current_slot]
shl edx, 8
shl ebx, 12 shl ebx, 12
add ebx, [SLOT_BASE+APPDATA.mem_size+edx] add ebx, [APPDATA.mem_size+edx]
call update_mem_size call update_mem_size
pop ebx pop ebx
@@: @@:

View File

@ -992,7 +992,7 @@ init_malloc:
mov [eax+12], eax mov [eax+12], eax
add eax, 16 add eax, 16
cmp eax, mst.smallbins+512 cmp eax, mst.smallbins+512
jl @B jb @B
ret ret

View File

@ -6,162 +6,6 @@ $Revision$
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
tmp_page_tab equ HEAP_BASE
align 4
proc mem_test
mov eax, cr0
and eax, not (CR0_CD+CR0_NW)
or eax, CR0_CD ;disable caching
mov cr0, eax
wbinvd ;invalidate cache
xor edi, edi
mov ebx, 'TEST'
@@:
add edi, 0x400000
xchg ebx, dword [edi]
cmp dword [edi], 'TEST'
xchg ebx, dword [edi]
je @b
mov [MEM_AMOUNT], edi
and eax, not (CR0_CD+CR0_NW) ;enable caching
mov cr0, eax
mov eax, edi
mov [LFBSize], 0x00800000
ret
endp
align 4
proc init_mem
mov eax, [MEM_AMOUNT]
mov [pg_data.mem_amount], eax
mov [pg_data.kernel_max], eax
shr eax, 12
mov edx, eax
mov [pg_data.pages_count], eax
mov [pg_data.kernel_pages], eax
shr eax, 3
mov [pg_data.pagemap_size], eax
shr edx, 10
cmp edx, 3
ja @f
inc edx ;at least 4Mb for kernel heap
@@:
mov [pg_data.kernel_tables], edx
xor eax, eax
mov edi, sys_pgdir
mov ecx, 2048
cld
rep stosd
mov edx, sys_pgdir
bt [cpu_caps], CAPS_PSE
jnc .no_PSE
mov ebx, cr4
or ebx, CR4_PSE
mov eax, PG_LARGE+PG_SW
bt [cpu_caps], CAPS_PGE
jnc @F
or eax, PG_GLOBAL
or ebx, CR4_PGE
@@:
mov cr4, ebx
sub [pg_data.kernel_tables], 2
mov [edx], eax
add eax, 0x00400000
mov [edx+4], eax
add edx, 8
mov eax, 0x800000+PG_SW
mov ecx, (HEAP_BASE-0x800000)/4096
jmp .map_low
.no_PSE:
mov eax, PG_SW
mov ecx, HEAP_BASE/4096
.map_low:
mov edi, tmp_page_tab
@@: ;
stosd
add eax, 0x1000
dec ecx
jnz @B
mov ecx, [pg_data.kernel_tables]
shl ecx, 10
xor eax, eax
rep stosd
mov ecx, [pg_data.kernel_tables]
mov eax, tmp_page_tab+PG_SW
mov edi, edx
.map_kernel_tabs:
stosd
add eax, 0x1000
dec ecx
jnz .map_kernel_tabs
mov dword [sys_pgdir+(page_tabs shr 20)], sys_pgdir+PG_SW
ret
endp
align 4
proc init_page_map
mov edi, sys_pgmap
mov ecx, (HEAP_BASE/4096)/32 ;384/4
mov ebx, ecx
xor eax,eax
cld
rep stosd
not eax
mov ecx, [pg_data.pagemap_size]
sub ecx, ebx
shr ecx, 2
rep stosd
lea edi, [sys_pgmap+ebx*4] ;+384
mov edx, [pg_data.pages_count]
mov ecx, [pg_data.kernel_tables]
add ecx, (HEAP_BASE/4096) and 31
sub edx, HEAP_BASE/4096
sub edx, ecx
mov [pg_data.pages_free], edx
xor eax, eax
mov ebx, ecx
shr ecx, 5
rep stosd
not eax
mov ecx, ebx
and ecx, 31
shl eax, cl
mov [page_start], edi; sys_pgmap+384
stosd
mov ebx, sys_pgmap
add ebx, [pg_data.pagemap_size]
mov [page_end], ebx
mov [pg_data.pg_mutex], 0
ret
endp
align 4 align 4
proc alloc_page proc alloc_page
@ -400,7 +244,7 @@ proc init_LFB
@@: @@:
mov edx, LFB_BASE mov edx, LFB_BASE
mov esi, [LFBAddress] mov esi, [LFBAddress]
mov edi, [LFBSize] mov edi, 0x00800000
mov dword [exp_lfb+4], edx mov dword [exp_lfb+4], edx
shr edi, 12 shr edi, 12
@ -410,10 +254,9 @@ proc init_LFB
bt [cpu_caps], CAPS_PSE bt [cpu_caps], CAPS_PSE
jnc .map_page_tables jnc .map_page_tables
or esi, PG_LARGE+PG_UW or esi, PG_LARGE+PG_UW
shr edx, 20 mov edx, sys_pgdir+(LFB_BASE shr 20)
mov ecx, edx
@@: @@:
mov [sys_pgdir+edx], esi mov [edx], esi
add edx, 4 add edx, 4
add esi, 0x00400000 add esi, 0x00400000
dec edi dec edi
@ -421,7 +264,7 @@ proc init_LFB
bt [cpu_caps], CAPS_PGE bt [cpu_caps], CAPS_PGE
jnc @F jnc @F
or dword [sys_pgdir+ecx], PG_GLOBAL or dword [sys_pgdir+(LFB_BASE shr 20)], PG_GLOBAL
@@: @@:
mov dword [LFBAddress], LFB_BASE mov dword [LFBAddress], LFB_BASE
mov eax, cr3 ;flush TLB mov eax, cr3 ;flush TLB
@ -430,11 +273,12 @@ proc init_LFB
.map_page_tables: .map_page_tables:
@@:
call alloc_page call alloc_page
stdcall map_page_table, edx, eax stdcall map_page_table, edx, eax
add edx, 0x00400000 add edx, 0x00400000
dec edi dec edi
jnz .map_page_tables jnz @B
mov eax, [LFBAddress] mov eax, [LFBAddress]
mov edi, page_tabs + (LFB_BASE shr 10) mov edi, page_tabs + (LFB_BASE shr 10)
@ -465,12 +309,11 @@ proc new_mem_resize stdcall, new_size:dword
and edi,not 4095 and edi,not 4095
mov [new_size], edi mov [new_size], edi
mov edx,[CURRENT_TASK] mov edx,[current_slot]
shl edx,8 cmp [edx+APPDATA.heap_base],0
cmp [SLOT_BASE+APPDATA.heap_base+edx],0
jne .exit jne .exit
mov esi, [SLOT_BASE+APPDATA.mem_size+edx] mov esi, [edx+APPDATA.mem_size]
add esi, 4095 add esi, 4095
and esi, not 4095 and esi, not 4095
@ -494,16 +337,13 @@ proc new_mem_resize stdcall, new_size:dword
jb @B jb @B
.update_size: .update_size:
mov ebx, [new_size] mov ebx, [new_size]
call update_mem_size call update_mem_size
xor eax, eax xor eax, eax
dec [pg_data.pg_mutex] dec [pg_data.pg_mutex]
ret ret
.expand: .expand:
add edi, new_app_base
add esi, new_app_base
push esi push esi
push edi push edi
@ -567,14 +407,14 @@ proc new_mem_resize stdcall, new_size:dword
endp endp
update_mem_size: update_mem_size:
; in: edx = slot shl 8 ; in: edx = slot base
; ebx = new memory size ; ebx = new memory size
; destroys eax,ecx,edx ; destroys eax,ecx,edx
mov [SLOT_BASE+APPDATA.mem_size+edx],ebx mov [APPDATA.mem_size+edx],ebx
;search threads and update ;search threads and update
;application memory size infomation ;application memory size infomation
mov ecx,[SLOT_BASE+APPDATA.dir_table+edx] mov ecx,[APPDATA.dir_table+edx]
mov eax,2 mov eax,2
.search_threads: .search_threads:
@ -610,53 +450,75 @@ get_pg_addr:
and eax, 0xFFFFF000 and eax, 0xFFFFF000
ret ret
align 4 align 4
proc page_fault_handler proc page_fault_handler
pushad
.err_code equ ebp+32
.err_addr equ ebp-4
pushad
mov ebp, esp mov ebp, esp
mov eax, cr2 mov eax, cr2
push eax push eax
push ds
push es
mov ax, 0x10 mov ax, app_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
inc [pg_data.pages_faults] inc [pg_data.pages_faults]
mov ebx, [ebp-4] ; push eax
; push edx
; mov edx, 0x400 ;bochs
; mov al,0xff ;bochs
; out dx, al ;bochs
; pop edx
; pop eax
cmp ebx, 0x80000000 mov ebx, [.err_addr]
jae .user_space mov eax, [.err_code]
cmp ebx, app_page_tabs cmp ebx, OS_BASE
jae .alloc jb .user_space ;ñòðàíèöà â ïàìÿòè ïðèëîæåíèÿ ;
cmp ebx, page_tabs cmp ebx, page_tabs
jae .tab_space jb .kernel_space ;ñòðàíèöà â ïàìÿòè ÿäðà
cmp ebx, 0x7DC00000 cmp ebx, kernel_tabs
jae .lfb_addr jb .alloc;.app_tabs ;òàáëèöû ñòðàíèö ïðèëîæåíèÿ ;
;ïðîñòî ñîçäàäèì îäíó
jmp .kernel_space cmp ebx, LFB_BASE
jb .core_tabs ;òàáëèöû ñòðàíèö ÿäðà
;Îøèáêà
.lfb:
;îáëàñòü LFB
;Îøèáêà
jmp .fail
align 4
.user_space: .user_space:
test eax, PG_MAP
jnz .err_access ;Ñòðàíèöà ïðèñóòñòâóåò
;Îøèáêà äîñòóïà ?
shr ebx, 12 shr ebx, 12
mov ecx, ebx mov ecx, ebx
shr ecx, 10 shr ecx, 10
mov edx, [master_tab+ecx*4] mov edx, [master_tab+ecx*4]
test edx, 1 test edx, PG_MAP
jz .fail jz .fail ;òàáëèöà ñòðàíèö íå ñîçäàíà
;íåâåðíûé àäðåñ â ïðîãðàììå
mov eax, [page_tabs+ebx*4] mov eax, [page_tabs+ebx*4]
test eax, 2 test eax, 2
jz .fail jz .fail ;àäðåñ íå çàðåçåðâèðîâàí äëÿ ;
;èñïîëüçîâàíèÿ. Îøèáêà
.alloc: .alloc:
call alloc_page call alloc_page
and eax, eax and eax, eax
jz .exit jz .fail
stdcall map_page,[ebp-4],eax,dword PG_UW stdcall map_page,[ebp-4],eax,dword PG_UW
@ -667,49 +529,76 @@ proc page_fault_handler
cld cld
rep stosd rep stosd
.exit: .exit:
pop es
pop ds
mov esp, ebp mov esp, ebp
popad popad
add esp, 4 add esp, 4
iretd iretd
.err_access:
;íèêîãäà íå ïðîèñõîäèò
jmp .fail
.kernel_space:
test eax, PG_MAP
jz .fail ;ñòðàíèöà íå ïðèñóòñòâóåò
test eax, 4 ;U/S
jnz .fail ;ïðèëîæåíèå îáðàòèëîñü ê ïàìÿòè
;ÿäðà
test eax, 8
jnz .fail ;óñòàíîâëåí çàðåçåðâèðîâàííûé áèò
;â òàáëèöàõ ñòðàíèö. äîáàâëåíî â P4/Xeon
;ïîïûòêà çàïèñè â çàùèù¸ííóþ ñòðàíèöó ÿäðà
cmp ebx, tss._io_map_0
jb .fail
cmp ebx, tss._io_map_0+8192
jae .fail
; io permission map
; copy-on-write protection
call alloc_page
and eax, eax
jz .fail
push eax
stdcall map_page,[ebp-4],eax,dword PG_SW
pop eax
mov edi, [.err_addr]
and edi, -4096
lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0
mov ebx, esi
shr ebx, 12
mov edx, [current_slot]
or eax, PG_SW
mov [edx+APPDATA.io_map+ebx*4], eax
add esi, [default_io_map]
mov ecx, 4096/4
cld
rep movsd
jmp .exit
;íå îáðàáàòûâàåì. Îøèáêà
.core_tabs:
.fail: .fail:
pop es
pop ds
mov esp, ebp mov esp, ebp
popad popad
add esp, 4 add esp, 4
; iretd
save_ring3_context ;debugger support save_ring3_context ;debugger support
mov bl, 14 mov bl, 14
jmp exc_c jmp exc_c
iretd iretd
.kernel_space:
; shr ebx, 12
; mov eax, [page_tabs+ebx*4]
; shr ebx, 10
; mov eax, [master_tab+ebx*4]
jmp .exit
.old_addr:
; shr ebx, 12
; mov eax, [page_tabs+ebx*4]
; shr ebx, 10
; mov eax, [master_tab+ebx*4]
jmp .exit
.lfb_addr:
; shr ebx, 22
; ;mov ecx, [sys_page_dir]
; mov eax, [master_tab+ebx*4]
jmp .exit
.tab_space:
; shr ebx, 12
; mov eax, [page_tabs+ebx*4]
; shr ebx, 10
; ;mov ecx, [sys_page_dir]
; mov eax, [master_tab+ebx*4]
jmp .exit
endp endp
align 4 align 4
@ -845,15 +734,12 @@ sys_IPC:
align 4 align 4
proc set_ipc_buff proc set_ipc_buff
mov eax,[CURRENT_TASK] mov eax,[current_slot]
shl eax,8
add eax, SLOT_BASE
pushf pushf
cli cli
mov [eax+0xA0],ebx ;set fields in extended information area mov [eax+APPDATA.ipc_start],ebx ;set fields in extended information area
mov [eax+0xA4],ecx mov [eax+APPDATA.ipc_size],ecx
add ebx, new_app_base
add ecx, ebx add ecx, ebx
add ecx, 4095 add ecx, 4095
and ecx, not 4095 and ecx, not 4095
@ -890,7 +776,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
jz .no_ipc_area jz .no_ipc_area
mov ebx, edi mov ebx, edi
add edi, new_app_base ; add edi, new_app_base
and ebx, 0xFFF and ebx, 0xFFF
mov [dst_offset], ebx mov [dst_offset], ebx
@ -924,7 +810,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov [edi+4], ecx mov [edi+4], ecx
add edi, 8 add edi, 8
mov esi, [msg_addr] mov esi, [msg_addr]
add esi, new_app_base ; add esi, new_app_base
cld cld
rep movsb rep movsb
@ -982,9 +868,9 @@ endp
align 4 align 4
sysfn_meminfo: sysfn_meminfo:
add ebx, new_app_base ; add ebx, new_app_base
cmp ebx, new_app_base cmp ebx, OS_BASE
jb .fail jae .fail
mov eax, [pg_data.pages_count] mov eax, [pg_data.pages_count]
mov [ebx], eax mov [ebx], eax
@ -1030,26 +916,23 @@ new_services:
@@: @@:
cmp eax, 13 cmp eax, 13
ja @f ja @f
add ebx, new_app_base
stdcall user_free, ebx stdcall user_free, ebx
mov [esp+36], eax mov [esp+36], eax
ret ret
@@: @@:
cmp eax, 14 cmp eax, 14
ja @f ja @f
add ebx, new_app_base cmp ebx, OS_BASE
cmp ebx, new_app_base jae .fail
jb .fail
stdcall get_event_ex, ebx, ecx stdcall get_event_ex, ebx, ecx
mov [esp+36], eax mov [esp+36], eax
ret ret
@@: @@:
cmp eax, 15 cmp eax, 15
ja @f ja @f
mov ecx, [CURRENT_TASK] mov ecx, [current_slot]
shl ecx, 8 mov eax, [ecx+APPDATA.fpu_handler]
mov eax, [ecx+SLOT_BASE+APPDATA.fpu_handler] mov [ecx+APPDATA.fpu_handler], ebx
mov [ecx+SLOT_BASE+APPDATA.fpu_handler], ebx
mov [esp+36], eax mov [esp+36], eax
ret ret
@@: @@:
@ -1058,9 +941,8 @@ new_services:
test ebx, ebx test ebx, ebx
jz .fail jz .fail
add ebx, new_app_base cmp ebx, OS_BASE
cmp ebx, new_app_base jae .fail
jb .fail
stdcall get_service, ebx stdcall get_service, ebx
mov [esp+36], eax mov [esp+36], eax
ret ret
@ -1073,18 +955,16 @@ new_services:
@@: @@:
cmp eax, 18 cmp eax, 18
ja @f ja @f
mov ecx, [CURRENT_TASK] mov ecx, [current_slot]
shl ecx, 8 mov eax, [ecx+APPDATA.sse_handler]
mov eax, [ecx+SLOT_BASE+APPDATA.sse_handler] mov [ecx+APPDATA.sse_handler], ebx
mov [ecx+SLOT_BASE+APPDATA.sse_handler], ebx
mov [esp+36], eax mov [esp+36], eax
ret ret
@@: @@:
cmp eax, 19 cmp eax, 19
ja @f ja @f
add ebx, new_app_base cmp ebx, OS_BASE
cmp ebx, new_app_base jae .fail
jb .fail
stdcall load_library, ebx stdcall load_library, ebx
mov [esp+36], eax mov [esp+36], eax
ret ret
@ -1102,144 +982,6 @@ new_services:
mov [esp+36], eax mov [esp+36], eax
ret ret
align 4
proc strncmp stdcall, str1:dword, str2:dword, count:dword
mov ecx,[count]
jecxz .end
mov ebx,ecx
mov edi,[str1]
mov esi,edi
xor eax,eax
repne scasb
neg ecx ; cx = count - strlen
add ecx,ebx ; strlen + count - strlen
.okay:
mov edi,esi
mov esi,[str2]
repe cmpsb
mov al,[esi-1]
xor ecx,ecx
cmp al,[edi-1]
ja .str2_big
je .end
.str1_big:
sub ecx,2
.str2_big:
not ecx
.end:
mov eax,ecx
ret
endp
align 4
proc test_cpu
locals
cpu_type dd ?
cpu_id dd ?
cpu_Intel dd ?
cpu_AMD dd ?
endl
mov [cpu_type], 0
xor eax, eax
mov [cpu_caps], eax
mov [cpu_caps+4], eax
pushfd
pop eax
mov ecx, eax
xor eax, 0x40000
push eax
popfd
pushfd
pop eax
xor eax, ecx
mov [cpu_type], CPU_386
jz .end_cpuid
push ecx
popfd
mov [cpu_type], CPU_486
mov eax, ecx
xor eax, 0x200000
push eax
popfd
pushfd
pop eax
xor eax, ecx
je .end_cpuid
mov [cpu_id], 1
xor eax, eax
cpuid
mov [cpu_vendor], ebx
mov [cpu_vendor+4], edx
mov [cpu_vendor+8], ecx
cmp ebx, dword [intel_str]
jne .check_AMD
cmp edx, dword [intel_str+4]
jne .check_AMD
cmp ecx, dword [intel_str+8]
jne .check_AMD
mov [cpu_Intel], 1
cmp eax, 1
jl .end_cpuid
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
.end_cpuid:
mov eax, [cpu_type]
ret
.check_AMD:
cmp ebx, dword [AMD_str]
jne .unknown
cmp edx, dword [AMD_str+4]
jne .unknown
cmp ecx, dword [AMD_str+8]
jne .unknown
mov [cpu_AMD], 1
cmp eax, 1
jl .unknown
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
.unknown:
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
endp
MEM_WB equ 6 ;write-back memory
MEM_WC equ 1 ;write combined memory
MEM_UC equ 0 ;uncached memory
align 4 align 4
proc init_mtrr proc init_mtrr
@ -1314,6 +1056,43 @@ proc set_mtrr stdcall, reg:dword,base:dword,size:dword,mem_type:dword
ret ret
endp endp
align 4
proc strncmp stdcall, str1:dword, str2:dword, count:dword
mov ecx,[count]
jecxz .end
mov ebx,ecx
mov edi,[str1]
mov esi,edi
xor eax,eax
repne scasb
neg ecx ; cx = count - strlen
add ecx,ebx ; strlen + count - strlen
.okay:
mov edi,esi
mov esi,[str2]
repe cmpsb
mov al,[esi-1]
xor ecx,ecx
cmp al,[edi-1]
ja .str2_big
je .end
.str1_big:
sub ecx,2
.str2_big:
not ecx
.end:
mov eax,ecx
ret
endp
align 4 align 4
proc stall stdcall, delay:dword proc stall stdcall, delay:dword
push ecx push ecx
@ -1341,106 +1120,6 @@ proc stall stdcall, delay:dword
ret ret
endp endp
iglobal
align 4
intel_str db "GenuineIntel",0
AMD_str db "AuthenticAMD",0
endg
uglobal
align 16
irq_tab rd 16
MEM_FreeSpace rd 1
ipc_tmp rd 1
ipc_pdir rd 1
ipc_ptab rd 1
proc_mem_map rd 1
proc_mem_pdir rd 1
proc_mem_tab rd 1
tmp_task_pdir rd 1
tmp_task_ptab rd 1
fdd_buff rd 1
LFBSize rd 1
stall_mcs rd 1
;;CPUID information
cpu_vendor rd 3
cpu_sign rd 1
cpu_info rd 1
;;;;; cursors data
align 16
cur_saved_data rb 4096
def_cursor rd 1
hw_cursor rd 1
scr_width rd 1
scr_height rd 1
cur_def_interl rd 1
cur_saved_base rd 1
cur_saved_interl rd 1
cur_saved_w rd 1
cur_saved_h rd 1
endg
uglobal
align 16
fpu_data:
rb 512
mst MEM_STATE
mem_block_map rb 512
event_map rb 64
mem_block_list rd 64
mem_block_mask rd 2
srv.fd rd 1
srv.bk rd 1
mem_used.fd rd 1
mem_used.bk rd 1
mem_block_arr rd 1
mem_block_start rd 1
mem_block_end rd 1
heap_mutex rd 1
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
free_blocks rd 1
page_start rd 1
page_end rd 1
events rd 1
event_start rd 1
event_end rd 1
event_uid rd 1
sys_page_map rd 1
os_stack rd 1
endg
if 0
push eax
push edx
mov edx, 0x400 ;bocsh
mov al,0xff ;bocsh
out dx, al ;bocsh
pop edx
pop eax
end if
align 4 align 4
k_strrchr: k_strrchr:
push eax push eax
@ -1660,3 +1339,15 @@ k_strlen:
ret ret
end if end if
if 0
push eax
push edx
mov edx, 0x400 ;bochs
mov al,0xff ;bochs
out dx, al ;bochs
pop edx
pop eax
end if

View File

@ -10,12 +10,14 @@ $Revision$
;; IRQ0 HANDLER (TIMER INTERRUPT) ;; ;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 32 align 32
irq0: irq0:
save_ring3_context ; pushfd
mov ax, os_data pushad
mov ds, ax mov ax, app_data ;
mov es, ax mov ds, ax
mov es, ax
inc dword [timer_ticks] inc dword [timer_ticks]
@ -27,8 +29,7 @@ irq0:
add eax,100 add eax,100
mov [next_usage_update],eax mov [next_usage_update],eax
call updatecputimes call updatecputimes
.nocounter: .nocounter:
cmp [DONT_SWITCH], byte 1 cmp [DONT_SWITCH], byte 1
jne .change_task jne .change_task
@ -38,10 +39,11 @@ irq0:
mov [DONT_SWITCH], byte 0 mov [DONT_SWITCH], byte 0
restore_ring3_context popad
iret ; popfd
iretd
.change_task: .change_task:
call update_counters call update_counters
call find_next_task call find_next_task
@ -56,9 +58,10 @@ irq0:
call do_change_task call do_change_task
.return: .return:
restore_ring3_context popad
iret ; popfd
iretd
align 4 align 4
@ -69,6 +72,9 @@ change_task:
pushad pushad
call update_counters call update_counters
if 0
; \begin{Mario79} ; \begin{Mario79}
cmp [dma_task_switched], 1 cmp [dma_task_switched], 1
jne .find_next_task jne .find_next_task
@ -82,6 +88,9 @@ change_task:
jmp @f jmp @f
.find_next_task: .find_next_task:
; \end{Mario79} ; \end{Mario79}
end if
call find_next_task call find_next_task
test eax, eax ; the same task -> skip switch test eax, eax ; the same task -> skip switch
jnz .return jnz .return
@ -89,10 +98,9 @@ change_task:
mov [DONT_SWITCH],byte 1 mov [DONT_SWITCH],byte 1
call do_change_task call do_change_task
.return: .return:
popad popad
popfd popfd
ret ret
@ -112,7 +120,7 @@ endg
update_counters: update_counters:
mov edi, [TASK_BASE] mov edi, [TASK_BASE]
mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
call _rdtsc rdtsc
sub eax, ebx sub eax, ebx
add eax, [edi+TASKDATA.counter_sum] ; counter sum add eax, [edi+TASKDATA.counter_sum] ; counter sum
mov [edi+TASKDATA.counter_sum], eax mov [edi+TASKDATA.counter_sum], eax
@ -130,15 +138,15 @@ find_next_task:
mov edi, [TASK_BASE] mov edi, [TASK_BASE]
mov [prev_slot], ebx mov [prev_slot], ebx
.waiting_for_termination: .waiting_for_termination:
.waiting_for_reuse: .waiting_for_reuse:
.waiting_for_event: .waiting_for_event:
.suspended: .suspended:
cmp ebx, [TASK_COUNT] cmp ebx, [TASK_COUNT]
jb @f jb @f
mov edi, CURRENT_TASK mov edi, CURRENT_TASK
xor ebx, ebx xor ebx, ebx
@@: @@:
add edi,0x20 add edi,0x20
inc ebx inc ebx
@ -159,12 +167,6 @@ find_next_task:
mov [CURRENT_TASK],ebx mov [CURRENT_TASK],ebx
mov [TASK_BASE],edi mov [TASK_BASE],edi
push ebx
shl ebx, 8
mov ebx, [SLOT_BASE + ebx + APPDATA.pl0_stack]
add ebx, RING0_STACK_SIZE
mov [CURRENT_RING0_ESP], ebx
pop ebx
cmp al, 5 cmp al, 5
jne .noevents jne .noevents
@ -173,30 +175,69 @@ find_next_task:
jz .waiting_for_event jz .waiting_for_event
mov [event_sched], eax mov [event_sched], eax
mov [edi+TASKDATA.state], byte 0 mov [edi+TASKDATA.state], byte 0
.noevents: .noevents:
.found: .found:
mov [CURRENT_TASK],ebx mov [CURRENT_TASK],ebx
mov [TASK_BASE],edi mov [TASK_BASE],edi
call _rdtsc rdtsc ;call _rdtsc
mov [edi+TASKDATA.counter_add],eax mov [edi+TASKDATA.counter_add],eax
mov esi, [prev_slot]
xor eax, eax xor eax, eax
cmp ebx, [prev_slot] cmp ebx, esi
sete al sete al
ret ret
; in: ebx = TSS selector index ; param
; ebx = incoming task
; esi = outcomig task
do_change_task: do_change_task:
shl ebx, 3
xor eax, eax shl ebx, 8
add ebx, tss0 add ebx, SLOT_BASE
mov [far_jump.sel], bx ; selector mov [current_slot], ebx
mov [far_jump.offs], eax ; offset
jmp pword [far_jump] shl esi, 8
add esi, SLOT_BASE
mov [esi+APPDATA.saved_esp], esp
mov esp, [ebx+APPDATA.saved_esp]
; set thread io map
mov ecx, [ebx+APPDATA.io_map]
mov edx, [ebx+APPDATA.io_map+4]
mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)], ecx
mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)], edx
mov eax, [ebx+APPDATA.dir_table]
mov cr3, eax
mov ebx, [ebx+APPDATA.pl0_stack]
add ebx, RING0_STACK_SIZE
mov [tss._esp0], ebx
mov ecx, cr0
or ecx, CR0_TS ;set task switch flag
mov cr0, ecx
inc [context_counter] ;noname & halyavin inc [context_counter] ;noname & halyavin
ret
test [ebx+APPDATA.dbg_state], 1
jnz @F
ret
@@:
mov eax, [ebx+APPDATA.dbg_regs.dr0]
mov dr0, eax
mov eax, [ebx+APPDATA.dbg_regs.dr1]
mov dr1, eax
mov eax, [ebx+APPDATA.dbg_regs.dr2]
mov dr2, eax
mov eax, [ebx+APPDATA.dbg_regs.dr3]
mov dr3, eax
xor eax, eax
mov dr6, eax
mov eax, [ebx+APPDATA.dbg_regs.dr7]
mov dr7, eax
ret
align 4 align 4
updatecputimes: updatecputimes:
@ -206,7 +247,7 @@ updatecputimes:
mov [idleuse],dword 0 mov [idleuse],dword 0
mov ecx, [TASK_COUNT] mov ecx, [TASK_COUNT]
mov edi, TASK_DATA mov edi, TASK_DATA
.newupdate: .newupdate:
mov ebx,[edi+TASKDATA.counter_sum] mov ebx,[edi+TASKDATA.counter_sum]
mov [edi+TASKDATA.cpu_usage],ebx mov [edi+TASKDATA.cpu_usage],ebx
mov [edi+TASKDATA.counter_sum],dword 0 mov [edi+TASKDATA.counter_sum],dword 0
@ -215,3 +256,108 @@ updatecputimes:
jnz .newupdate jnz .newupdate
ret ret
if 0
struc TIMER
{
.next dd ?
.exp_time dd ?
.func dd ?
.arg dd ?
}
MAX_PROIRITY 0 ; highest, used for kernel tasks
MAX_USER_PRIORITY 0 ; highest priority for user processes
USER_PRIORITY 7 ; default (should correspond to nice 0)
MIN_USER_PRIORITY 14 ; minimum priority for user processes
IDLE_PRIORITY 15 ; lowest, only IDLE process goes here
NR_SCHED_QUEUES 16 ; MUST equal IDLE_PRIORYTY + 1
rdy_head rd 16
align 4
pick_task:
xor eax, eax
.pick:
mov ebx, [rdy_head+eax*4]
test ebx, ebx
jz .next
mov [next_task], ebx
test [ebx+flags.billable]
jz @F
mov [bill_task], ebx
@@:
ret
.next:
inc eax
jmp .pick
; param
; eax= task
;
; retval
; eax= task
; ebx= queue
; ecx= front if 1 or back if 0
align 4
shed:
cmp [eax+.tics_left], 0 ;signed compare
mov ebx, [eax+.priority]
setg ecx
jg @F
mov edx, [eax+.tics_quantum]
mov [eax+.ticks_left], edx
cmp ebx, (IDLE_PRIORITY-1)
je @F
inc ebx
@@:
ret
; param
; eax= task
align 4
enqueue:
call shed ;eax
cmp [rdy_head+ebx*4],0
jnz @F
mov [rdy_head+ebx*4], eax
mov [rdy_tail+ebx*4], eax
mov [eax+.next_ready], 0
jmp .pick
@@:
test ecx, ecx
jz .back
mov ecx, [rdy_head+ebx*4]
mov [eax+.next_ready], ecx
mov [rdy_head+ebx*4], eax
jmp .pick
.back:
mov ecx, [rdy_tail+ebx*4]
mov [ecx+.next_ready], eax
mov [rdy_tail+ebx*4], eax
mov [eax+.next_ready], 0
.pick:
call pick_proc ;select next task
ret
end if

View File

@ -17,25 +17,6 @@ idtreg:
dw 8*0x41-1 dw 8*0x41-1
dd idts+8 dd idts+8
build_process_gdt_tss_pointer:
mov ecx,tss_data
mov edi,0
setgdtl2:
mov [edi+gdts+ tss0 +0], word tss_step
mov [edi+gdts+ tss0 +2], cx
mov eax,ecx
shr eax,16
mov [edi+gdts+ tss0 +4], al
mov [edi+gdts+ tss0 +7], ah
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
add ecx,tss_step
add edi,8
cmp edi,8*(max_processes+5)
jbe setgdtl2
ret
build_interrupt_table: build_interrupt_table:
mov edi, idts+8 mov edi, idts+8
@ -43,11 +24,11 @@ build_interrupt_table:
mov ecx, 0x40 mov ecx, 0x40
@@: @@:
lodsd lodsd
mov [edi], ax ; lower part of offset mov [edi], ax ; lower part of offset
mov [edi+2], word os_code ; segment selector mov [edi+2], word os_code ; segment selector
mov ax, word 10001110b shl 8 ; type: interrupt gate mov ax, word 10001110b shl 8 ; type: interrupt gate
mov [edi+4], eax mov [edi+4], eax
add edi, 8 add edi, 8
loop @b loop @b
;mov edi,8*0x40+idts+8 ;mov edi,8*0x40+idts+8
@ -67,7 +48,7 @@ iglobal
times 12 dd unknown_interrupt times 12 dd unknown_interrupt
dd irq0 , irq_serv.irq_1, p_irq2 , p_irq3 ;irq_serv.irq_3 dd irq0 , irq_serv.irq_1, p_irq2 , p_irq3 ;irq_serv.irq_3
dd p_irq4 ,irq_serv.irq_5,p_irq6,irq_serv.irq_7 dd irq_serv.irq_4 ,irq_serv.irq_5,p_irq6,irq_serv.irq_7
dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10
dd irq_serv.irq_11,p_irq12,irqD ,p_irq14,p_irq15 dd irq_serv.irq_11,p_irq12,irqD ,p_irq14,p_irq15
@ -78,13 +59,11 @@ endg
macro save_ring3_context macro save_ring3_context
{ {
push ds es
pushad pushad
} }
macro restore_ring3_context macro restore_ring3_context
{ {
popad popad
pop es ds
} }
; simply return control to interrupted process ; simply return control to interrupted process
@ -114,20 +93,19 @@ exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18
exc_w_code 8, 10, 11, 12, 13, 14, 17 exc_w_code 8, 10, 11, 12, 13, 14, 17
exc_c: exc_c:
mov ax, os_data mov ax, app_data ;èñêëþ÷åíèå
mov ds, ax mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè
mov es, ax mov es, ax ;â ðåãèñòðû
; test if debugging ; test if debugging
cli cli
mov eax, [CURRENT_TASK] mov eax, [current_slot]
shl eax, 8 mov eax, [eax+APPDATA.debugger_slot]
mov eax, [SLOT_BASE+eax+APPDATA.debugger_slot]
test eax, eax test eax, eax
jnz .debug jnz .debug
sti sti
; not debuggee => say error and terminate ; not debuggee => say error and terminate
add esp, 28h add esp, 0x20 ;28h
movzx eax, bl movzx eax, bl
mov [error_interrupt], eax mov [error_interrupt], eax
call show_error_parameters call show_error_parameters
@ -242,8 +220,8 @@ macro irqh [num]
irqh 2,5,7,8,9,10,11 irqh 2,5,7,8,9,10,11
irq_c: irq_c:
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call irqhandler call irqhandler
@ -252,7 +230,7 @@ irqh 2,5,7,8,9,10,11
p_irq6: p_irq6:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call fdc_irq call fdc_irq
@ -262,7 +240,7 @@ p_irq6:
p_irq3: p_irq3:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
cmp [com2_mouse_detected],0 cmp [com2_mouse_detected],0
@ -278,7 +256,7 @@ p_irq3:
p_irq4: p_irq4:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
cmp [com1_mouse_detected],0 cmp [com1_mouse_detected],0
@ -294,7 +272,7 @@ p_irq4:
p_irq12: p_irq12:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call check_mouse_data_ps2 call check_mouse_data_ps2
@ -303,7 +281,7 @@ p_irq12:
p_irq14: p_irq14:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call [irq14_func] call [irq14_func]
@ -312,7 +290,7 @@ p_irq14:
iret iret
p_irq15: p_irq15:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call [irq15_func] call [irq15_func]
@ -335,7 +313,7 @@ ready_for_next_irq_1:
irqD: irqD:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
@ -674,6 +652,17 @@ term9:
mov edi, [.slot] mov edi, [.slot]
shl edi,8 shl edi,8
add edi,SLOT_BASE add edi,SLOT_BASE
mov eax, [edi+APPDATA.io_map]
cmp eax, (tss._io_map_0-OS_BASE+PG_MAP)
je @F
call free_page
@@:
mov eax, [edi+APPDATA.io_map+4]
cmp eax, (tss._io_map_1-OS_BASE+PG_MAP)
je @F
call free_page
@@:
mov eax, 0x20202020 mov eax, 0x20202020
stosd stosd
stosd stosd
@ -837,13 +826,12 @@ endg
build_scheduler: build_scheduler:
; mov esi,boot_sched_1 mov esi,boot_sched_1
; call boot_log call boot_log
call build_process_gdt_tss_pointer ; call build_process_gdt_tss_pointer
; mov esi,boot_sched_2 ; mov esi,boot_sched_2
; call boot_log ; call boot_log
call build_interrupt_table
ret ret

View File

@ -12,17 +12,16 @@ $Revision$
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 32 align 16
i40: i40:
; diamond, 27.03.2007: handler does not require disabled interrupts ; diamond, 27.03.2007: handler does not require disabled interrupts
; so interrupts remain enabled when calling int 0x40 ; so interrupts remain enabled when calling int 0x40
push ds es
pushad pushad
cld cld
mov ax,word os_data ; mov ax, word app_data
mov ds,ax ; mov ds, ax
mov es,ax ; mov es, ax
; load all registers in crossed order ; load all registers in crossed order
mov eax, ebx mov eax, ebx
@ -38,10 +37,8 @@ i40:
and edi,0xff and edi,0xff
call dword [servetable+edi*4] call dword [servetable+edi*4]
pop eax pop eax
; cli
popad popad
pop es ds
iretd iretd
@ -67,18 +64,13 @@ sysenter_entry:
; mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack] ; mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack]
; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP
; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app
mov esp, [ss:CURRENT_RING0_ESP] mov esp, [ss:tss._esp0]
sti sti
;------------------ ;------------------
push ds es
pushad pushad
cld cld
mov ax, word os_data
mov ds, ax
mov es, ax
mov eax, ebx mov eax, ebx
mov ebx, ecx mov ebx, ecx
mov ecx, edx mov ecx, edx
@ -92,10 +84,9 @@ sysenter_entry:
pop eax pop eax
popad popad
pop es ds
;------------------ ;------------------
mov edx, [SYSENTER_VAR] ; eip mov edx, [SYSENTER_VAR] ; eip
mov ecx, [SYSENTER_VAR + 4] ; esp mov ecx, [SYSENTER_VAR + 4] ; esp
sysexit sysexit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -105,12 +96,11 @@ sysenter_entry:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 32 align 32
syscall_entry: syscall_entry:
; cli syscall clear IF ; cli syscall clear IF
xchg esp, [ss:CURRENT_RING0_ESP] xchg esp, [ss:tss._esp0]
push ecx push ecx
lea ecx, [esp+4] lea ecx, [esp+4]
xchg ecx, [ss:CURRENT_RING0_ESP] xchg ecx, [ss:tss._esp0]
sti sti
push ecx push ecx
mov ecx, [ecx] mov ecx, [ecx]
@ -123,13 +113,12 @@ syscall_entry:
; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app
;------------------ ;------------------
push ds es
pushad pushad
cld cld
mov ax, word os_data ; mov ax, word app_data
mov ds, ax ; mov ds, ax
mov es, ax ; mov es, ax
mov eax, ebx mov eax, ebx
mov ebx, ecx mov ebx, ecx
@ -144,13 +133,11 @@ syscall_entry:
pop eax pop eax
popad popad
pop es ds
;------------------ ;------------------
mov ecx, [ss:esp+4] mov ecx, [ss:esp+4]
pop esp pop esp
sysret sysret
iglobal iglobal
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SYSTEM FUNCTIONS TABLE ;; ;; SYSTEM FUNCTIONS TABLE ;;

View File

@ -28,40 +28,6 @@ struc APP_HEADER_01
.i_icon dd ? ;+32 .i_icon dd ? ;+32
} }
struc TSS
{
._back rw 2
._esp0 rd 1
._ss0 rw 2
._esp1 rd 1
._ss1 rw 2
._esp2 rd 1
._ss2 rw 2
._cr3 rd 1
._eip rd 1
._eflags rd 1
._eax rd 1
._ecx rd 1
._edx rd 1
._ebx rd 1
._esp rd 1
._ebp rd 1
._esi rd 1
._edi rd 1
._es rw 2
._cs rw 2
._ss rw 2
._ds rw 2
._fs rw 2
._gs rw 2
._ldt rw 2
._trap rw 1
._io rw 1
}
virtual at 0
TSS TSS
end virtual
struc APP_PARAMS struc APP_PARAMS
{ .app_cmdline ;0x00 { .app_cmdline ;0x00
@ -154,9 +120,6 @@ proc fs_execute
cmp eax, 0 cmp eax, 0
jne .wait_lock jne .wait_lock
; pushfd
; cli
call set_application_table_status call set_application_table_status
call get_new_process_place call get_new_process_place
@ -216,7 +179,7 @@ else
jna @F jna @F
xor eax, eax xor eax, eax
add edi, new_app_base ; add edi, new_app_base
cld cld
rep stosb rep stosb
@@: @@:
@ -395,21 +358,21 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
mov [dir_addr], eax mov [dir_addr], eax
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW stdcall map_page,[tmp_task_pdir],eax,dword PG_SW
mov esi, sys_pgdir
mov edi, [tmp_task_pdir] mov edi, [tmp_task_pdir]
mov ecx, (page_tabs shr 20)/4 mov ecx, (OS_BASE shr 20)/4
xor eax, eax
cld cld
rep stosd
mov ecx, (OS_BASE shr 20)/4
mov esi, sys_pgdir+(OS_BASE shr 20)
rep movsd rep movsd
mov eax, [dir_addr] mov eax, [dir_addr]
or eax, PG_SW or eax, PG_SW
stosd ; [(page_tabs shr 20)]= eax mov [edi-4096+(page_tabs shr 20)], eax
mov ecx, 0x800/4 and eax, -4096
xor eax, eax
rep stosd
mov eax, [dir_addr]
call set_cr3 call set_cr3
mov edx, [app_tabs] mov edx, [app_tabs]
@ -494,13 +457,9 @@ endp
align 4 align 4
set_cr3: set_cr3:
mov esi, [CURRENT_TASK]
mov ebx, esi mov ebx, [current_slot]
shl esi,8 mov [ebx+APPDATA.dir_table], eax
mov [SLOT_BASE+esi+0xB8],eax
imul ebx,tss_step
add ebx,tss_data
mov [ebx+28], eax
mov cr3, eax mov cr3, eax
ret ret
@ -558,8 +517,7 @@ proc destroy_app_space stdcall, pg_dir:dword
and eax, not 0xFFF and eax, not 0xFFF
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW stdcall map_page,[tmp_task_pdir],eax,dword PG_SW
mov esi, [tmp_task_pdir] mov esi, [tmp_task_pdir]
add esi, 0x800 mov edi, (OS_BASE shr 20)/4
mov edi, 0x800/4
.destroy: .destroy:
mov eax, [esi] mov eax, [esi]
test eax, 1 test eax, 1
@ -744,7 +702,7 @@ proc read_process_memory
mov eax, [slot] mov eax, [slot]
shl eax,8 shl eax,8
mov ebx, [offset] mov ebx, [offset]
add ebx, new_app_base ; add ebx, new_app_base
push ecx push ecx
stdcall map_memEx, [proc_mem_map],\ stdcall map_memEx, [proc_mem_map],\
[SLOT_BASE+eax+0xB8],\ [SLOT_BASE+eax+0xB8],\
@ -810,7 +768,7 @@ proc write_process_memory
mov eax, [slot] mov eax, [slot]
shl eax,8 shl eax,8
mov ebx, [offset] mov ebx, [offset]
add ebx, new_app_base ; add ebx, new_app_base
push ecx push ecx
stdcall map_memEx, [proc_mem_map],\ stdcall map_memEx, [proc_mem_map],\
[SLOT_BASE+eax+0xB8],\ [SLOT_BASE+eax+0xB8],\
@ -875,9 +833,7 @@ proc new_sys_threads
mov [slot], eax mov [slot], eax
mov esi,[CURRENT_TASK] mov esi,[current_slot]
shl esi,8
add esi,SLOT_BASE
mov ebx,esi ;ebx=esi - pointer to extended information about current thread mov ebx,esi ;ebx=esi - pointer to extended information about current thread
mov edi, eax mov edi, eax
@ -942,6 +898,12 @@ wait_mutex:
pop eax pop eax
ret ret
EFL_IF equ 0x0200
EFL_IOPL1 equ 0x1000
EFL_IOPL2 equ 0x2000
EFL_IOPL3 equ 0x3000
align 4 align 4
proc set_app_params stdcall,slot:dword, params:dword,\ proc set_app_params stdcall,slot:dword, params:dword,\
cmd_line:dword, app_path:dword, flags:dword cmd_line:dword, app_path:dword, flags:dword
@ -963,9 +925,14 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0 mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0
mov [eax+SLOT_BASE+APPDATA.sse_handler], 0 mov [eax+SLOT_BASE+APPDATA.sse_handler], 0
;set default io permission map
mov [eax+SLOT_BASE+APPDATA.io_map],\
(tss._io_map_0-OS_BASE+PG_MAP)
mov [eax+SLOT_BASE+APPDATA.io_map+4],\
(tss._io_map_1-OS_BASE+PG_MAP)
mov esi, fpu_data mov esi, fpu_data
mov ecx, 512/4 mov ecx, 512/4
cld
rep movsd rep movsd
cmp ebx,[TASK_COUNT] cmp ebx,[TASK_COUNT]
@ -1003,24 +970,24 @@ proc set_app_params stdcall,slot:dword, params:dword,\
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
ja @f ja @f
add edx, new_app_base
stdcall k_strncpy, edx, [cmd_line], 256 stdcall k_strncpy, edx, [cmd_line], 256
@@: @@:
mov edx,[params] mov edx,[params]
mov edx, [edx+4] ;app_path mov edx, [edx+4] ;app_path
test edx,edx test edx,edx
jz @F ;application don't need path of file jz @F ;application don't need path of file
mov eax, edx mov eax, edx
add eax, 1024 add eax, 1024
jc @f jc @f
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
ja @f ja @f
add edx, new_app_base
stdcall k_strncpy, edx, [app_path], 1024 stdcall k_strncpy, edx, [app_path], 1024
@@: @@:
mov ebx,[slot] mov ebx,[slot]
mov eax,ebx mov eax,ebx
shl ebx,5 shl ebx,5
lea ecx,[draw_data+ebx] ;ecx - pointer to draw data
; set window state to 'normal' (non-minimized/maximized/rolled-up) state ; set window state to 'normal' (non-minimized/maximized/rolled-up) state
mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL
mov [ebx+window_data+WDATA.fl_redraw], 1 mov [ebx+window_data+WDATA.fl_redraw], 1
@ -1033,8 +1000,6 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov eax,[process_number] mov eax,[process_number]
mov [ebx+4],eax ;set PID mov [ebx+4],eax ;set PID
mov ecx,ebx
add ecx,(draw_data-CURRENT_TASK) ;ecx - pointer to draw data
;set draw data to full screen ;set draw data to full screen
mov [ecx+0],dword 0 mov [ecx+0],dword 0
@ -1044,54 +1009,34 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov eax,[ScreenHeight] mov eax,[ScreenHeight]
mov [ecx+12],eax mov [ecx+12],eax
mov edi,[slot]
imul edi,tss_step
add edi,tss_data
mov ecx,128/4
xor eax, eax
cld
rep stosd
;Add IO access table - bit array of permitted ports
not eax
mov ecx,2048
rep stosd ; access to 4096*8=65536 ports
sub edi, tss_step
;set cr3 register in TSS of application
mov ecx, [slot]
shl ecx, 8
mov eax,[SLOT_BASE+ecx+APPDATA.dir_table]
mov [edi+TSS._cr3],eax
mov esi,[params]
mov eax, [esi+0x08] ;app_eip
mov [edi+TSS._eip],eax ;set eip in TSS
mov eax, [esi+0x0C] ;app_esp
mov [edi+TSS._esp],eax ;set stack in TSS
mov [edi+TSS._eflags],dword 0x1202
mov [edi+TSS._cs],app_code ;selector of code segment
mov [edi+TSS._ss],app_data
mov [edi+TSS._ds],app_data
mov [edi+TSS._es],app_data
mov [edi+TSS._fs],app_data
mov [edi+TSS._gs],graph_data ;selector of graphic segment
mov [edi+TSS._io],word 128
mov [edi+TSS._ss0], os_data
mov ebx, [pl0_stack] mov ebx, [pl0_stack]
add ebx, RING0_STACK_SIZE mov esi,[params]
mov [edi+TSS._esp0],ebx lea ecx, [ebx+REG_EIP]
xor eax, eax
mov ecx, edi ;ecx - address of application TSS mov [ebx+REG_RET], dword irq0.return
mov ebx,[slot] mov [ebx+REG_EDI], eax
shl ebx,3 mov [ebx+REG_ESI], eax
;set TSS descriptor mov [ebx+REG_EBP], eax
mov [ebx+gdts+tss0+0],word tss_step ;limit (size) mov [ebx+REG_ESP], ecx ;ebx+REG_EIP
mov [ebx+gdts+tss0+2],cx ;part of offset mov [ebx+REG_EBX], eax
shr ecx,16 mov [ebx+REG_EDX], eax
mov [ebx+gdts+tss0+4],cl ;part of offset mov [ebx+REG_ECX], eax
mov [ebx+gdts+tss0+7],ch ;part of offset mov [ebx+REG_EAX], eax
mov [ebx+gdts+tss0+5],word 01010000b*256+11101001b ;system flags
mov eax, [esi+0x08] ;app_eip
mov [ebx+REG_EIP], eax ;app_entry
mov [ebx+REG_CS], dword app_code
mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
mov eax, [esi+0x0C] ;app_esp
mov [ebx+REG_APP_ESP], eax ;app_stack
mov [ebx+REG_SS], dword app_data
lea ecx, [ebx+REG_RET]
mov ebx, [slot]
shl ebx, 8
mov [ebx+SLOT_BASE+APPDATA.saved_esp], ecx
;flush keyboard and buttons queue ;flush keyboard and buttons queue
mov [KEY_COUNT],byte 0 mov [KEY_COUNT],byte 0
@ -1121,13 +1066,5 @@ proc set_app_params stdcall,slot:dword, params:dword,\
ret ret
endp endp
include "debug.inc" include "debug.inc"
iglobal
new_process_loading db 'K : New Process - loading',13,10,0
new_process_running db 'K : New Process - done',13,10,0
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
endg

58
kernel/trunk/data16.inc Normal file
View File

@ -0,0 +1,58 @@
$Revision$
flm db 0
preboot_lfb db 0
preboot_bootlog db 0
align 4
old_ints_h:
dw 0x400
dd 0
dw 0
kernel_restart_bootblock:
db 1 ; version
dw 1 ; floppy image is in memory
dd 0 ; cannot save parameters
align 4
; videomodes table
gr_table:
dw 0x112+0100000000000000b , 640 , 480 ; 1
dw 0x115+0100000000000000b , 800 , 600 ; 2
dw 0x118+0100000000000000b , 1024 , 768 ; 3
dw 0x11B+0100000000000000b , 1280 , 1024 ; 4
dw 0x112 , 640 , 480 ; 5
dw 0x115 , 800 , 600 ; 6
dw 0x118 , 1024 , 768 ; 7
dw 0x11B , 1280 ,1024 ; 8
dw 0x13, 640, 480 ; 9
dw 0x12, 640, 480 ; 0
; table for move to extended memory (int 15h, ah=87h)
align 8
movedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
fwmovedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0

338
kernel/trunk/data32.inc Normal file
View File

@ -0,0 +1,338 @@
$Revision$
keymap:
db '6',27
db '1234567890-=',8,9
db 'qwertyuiop[]',13
db '~asdfghjkl;',39,96,0,'\zxcvbnm,./',0,'45 '
db '@234567890123',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'AB<D',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
keymap_shift:
db '6',27
db '!@#$%^&*()_+',8,9
db 'QWERTYUIOP{}',13
db '~ASDFGHJKL:"~',0,'|ZXCVBNM<>?',0,'45 '
db '@234567890123',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'AB>D',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
keymap_alt:
db ' ',27
db ' @ $ {[]}\ ',8,9
db ' ',13
db ' ',0,' ',0,'4',0,' '
db ' ',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'ABCD',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
boot_memdetect db 'Determining amount of memory',0
boot_fonts db 'Fonts loaded',0
boot_tss db 'Setting TSSs',0
boot_cpuid db 'Reading CPUIDs',0
boot_devices db 'Detecting devices',0
boot_timer db 'Setting timer',0
boot_irqs db 'Reprogramming IRQs',0
boot_setmouse db 'Setting mouse',0
boot_windefs db 'Setting window defaults',0
boot_bgr db 'Calculating background',0
boot_resirqports db 'Reserving IRQs & ports',0
boot_setrports db 'Setting addresses for IRQs',0
boot_setostask db 'Setting OS task',0
boot_allirqs db 'Unmasking all IRQs',0
boot_tsc db 'Reading TSC',0
boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0
boot_pal_vga db 'Setting VGA 640x480 palette',0
boot_mtrr db 'Setting MTRR',0
boot_tasking db 'All set - press ESC to start',0
new_process_loading db 'K : New Process - loading',13,10,0
new_process_running db 'K : New Process - done',13,10,0
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
msg_unresolved db 'unresolved ',0
msg_module db 'in module ',0
msg_version db 'incompatible driver version',13,10,0
msg_www db 'please visit www.kolibrios.org',13,10,0
msg_CR db 13,10,0
intel_str db "GenuineIntel",0
AMD_str db "AuthenticAMD",0
;szSound db 'SOUND',0
;szInfinity db 'INFINITY',0
szHwMouse db 'ATI2D',0
szSTART db 'START',0
szEXPORTS db 'EXPORTS',0
szIMPORTS db 'IMPORTS',0
firstapp db '/rd/1/LAUNCHER',0
char db 'FONTS/CHAR.MT',0
char2 db 'FONTS/CHAR2.MT',0
bootpath db '/KOLIBRI '
bootpath2 db 0
vmode db 'drivers/VMODE.MDR',0
vrr_m db '/rd/1/VRR_M',0
kernel_file db 'KERNEL MNT'
; mike.dld {
db 0
dd servetable-0x10000
draw_line dd __sys_draw_line
disable_mouse dd __sys_disable_mouse
draw_pointer dd __sys_draw_pointer
;//mike.dld, 2006-08-02 [
;drawbar dd __sys_drawbar
drawbar dd __sys_drawbar.forced
;//mike.dld, 2006-08-02 ]
putpixel dd __sys_putpixel
; } mike.dld
align 4
keyboard dd 1
sound_dma dd 1
syslang dd 1
boot_y dd 10
if __DEBUG__ eq 1
include_debug_strings
end if
IncludeIGlobals
align 16
gdts:
dw gdte-$-1
dd gdts
dw 0
; Attention! The order first four selectors not to change, is used in Fast System Call
; must be : os_code, os_data, app_code, app_data, ....
int_code_l:
os_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011010b
db 0x00
int_data_l:
os_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
app_code_l:
dw 0xFFFF
dw 0
db 0
db cpl3
dw G32+D32+(new_app_base shr 16)+0xF;
app_data_l:
dw 0xFFFF
dw 0
db 0
db drw3
dw G32+D32+(new_app_base shr 16)+0xF;
; --------------- APM ---------------------
apm_code_32:
dw 0x0f ; limit 64kb
db 0, 0, 0
dw 11010000b *256 +10011010b
db 0x00
apm_code_16:
dw 0x0f
db 0, 0, 0
dw 10010000b *256 +10011010b
db 0x00
apm_data_16:
dw 0x0f
db 0, 0, 0
dw 10010000b *256 +10010010b
db 0x00
; -----------------------------------------
graph_data_l:
dw 0x7ff
dw 0x0000
db 0x00
dw 11010000b *256 +11110010b
db 0x00
tss0_l:
dw TSS_SIZE-1
dw tss and 0xFFFF
db (tss shr 16) and 0xFF
db 10001001b
dw (tss shr 16) and 0xFF00
endofcode:
gdte:
align 16
cur_saved_data rb 4096
fpu_data: rb 512
; device irq owners
irq_owner rd 16 ; process id
; on irq read ports
irq00read rd 16
irq01read rd 16
irq02read rd 16
irq03read rd 16
irq04read rd 16
irq05read rd 16
irq06read rd 16
irq07read rd 16
irq08read rd 16
irq09read rd 16
irq10read rd 16
irq11read rd 16
irq12read rd 16
irq13read rd 16
irq14read rd 16
irq15read rd 16
irq_tab rd 16
mem_block_map rb 512
event_map rb 64
mem_block_list rd 64
mem_block_mask rd 2
mem_used.fd rd 1
mem_used.bk rd 1
mem_block_arr rd 1
mem_block_start rd 1
mem_block_end rd 1
heap_mutex rd 1
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
free_blocks rd 1
mst MEM_STATE
page_start rd 1
page_end rd 1
events rd 1
event_start rd 1
event_end rd 1
event_uid rd 1
sys_page_map rd 1
os_stack_seg rd 1
srv.fd rd 1
srv.bk rd 1
scr_width rd 1
scr_height rd 1
create_cursor rd 1
set_hw_cursor rd 1
hw_restore rd 1
def_cursor rd 1
hw_cursor rd 1
cur_def_interl rd 1
cur_saved_base rd 1
cur_saved_interl rd 1
cur_saved_w rd 1
cur_saved_h rd 1
ipc_tmp rd 1
ipc_pdir rd 1
ipc_ptab rd 1
proc_mem_map rd 1
proc_mem_pdir rd 1
proc_mem_tab rd 1
tmp_task_pdir rd 1
tmp_task_ptab rd 1
default_io_map rd 1
LFBSize rd 1
stall_mcs rd 1
current_slot rd 1
; status
hd1_status rd 1 ; 0 - free : other - pid
application_table_status rd 1 ; 0 - free : other - pid
; device addresses
mididp rd 1
midisp rd 1
cdbase rd 1
cdid rd 1
hdbase rd 1 ; for boot 0x1f0
hdid rd 1
hdpos rd 1 ; for boot 0x1
fat32part rd 1 ; for boot 0x1
sb16 rd 1
;CPUID information
cpu_vendor rd 3
cpu_sign rd 1
cpu_info rd 1
cpu_caps rd 4
pg_data PG_DATA
heap_test rd 1
buttontype rd 1
windowtypechanged rd 1
hd_entries rd 1 ;unused ? 0xfe10
;* start code - Mario79
mouse_active rd 1
mouse_pause rd 1
MouseTickCounter rd 1
ps2_mouse_detected rb 1
com1_mouse_detected rb 1
com2_mouse_detected rb 1
;* end code - Mario79
wraw_bacground_select rb 1
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
IncludeUGlobals

View File

@ -25,7 +25,7 @@ Detect_COM_Mouse:
mov eax,4 mov eax,4
shl eax,2 shl eax,2
mov [irq_owner+eax],byte 1 mov [irq_owner+eax], 1
inc dword [RESERVED_PORTS] inc dword [RESERVED_PORTS]
mov edi,[RESERVED_PORTS] mov edi,[RESERVED_PORTS]
@ -47,7 +47,7 @@ Detect_COM_Mouse:
mov eax,3 mov eax,3
shl eax,2 shl eax,2
mov [irq_owner+eax],byte 1 mov [irq_owner+eax], 1
inc dword [RESERVED_PORTS] inc dword [RESERVED_PORTS]
mov edi,[RESERVED_PORTS] mov edi,[RESERVED_PORTS]

View File

@ -10,16 +10,18 @@ format MS COFF
include 'proc32.inc' include 'proc32.inc'
include 'imports.inc' include 'imports.inc'
DEBUG equ 1 API_VERSION equ 0x01000100
VID_ATI equ 0x1002 DEBUG equ 1
VID_ATI equ 0x1002
LOAD_FROM_FILE equ 0 LOAD_FROM_FILE equ 0
LOAD_FROM_MEM equ 1 LOAD_FROM_MEM equ 1
LOAD_INDIRECT equ 2 LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3 LOAD_SYSTEM equ 3
VIDEO_FREE equ 2 SRV_GETVERSION equ 0
struc BITMAPINFOHEADER { struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD .biSize dd ? ; DWORD
@ -71,9 +73,8 @@ R9800 equ 0x4E49 ;R350
R9800P equ 0x4E48 ;R350 R9800P equ 0x4E48 ;R350
R9800XT equ 0x4E4A ;R360 R9800XT equ 0x4E4A ;R360
OS_BASE equ 0 OS_BASE equ 0x80000000
new_app_base equ 0x80000000 SLOT_BASE equ (OS_BASE+0x0080000)
SLOT_BASE equ 0x0080000
PG_SW equ 0x003 PG_SW equ 0x003
PG_NOCACHE equ 0x018 PG_NOCACHE equ 0x018
@ -230,13 +231,16 @@ out_size equ IOCTL.out_size
align 4 align 4
proc service_proc stdcall, ioctl:dword proc service_proc stdcall, ioctl:dword
mov edi, [ioctl] mov ebx, [ioctl]
mov ebx, [edi+io_code] cmp [ebx+io_code], SRV_GETVERSION
cmp ebx, VIDEO_FREE
jne .fail jne .fail
mov eax, [edi+input] mov eax, [ebx+output]
call video_free cmp [ebx+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
.fail: .fail:
or eax, -1 or eax, -1
ret ret
@ -987,7 +991,7 @@ devices dd (R8500 shl 16)+VID_ATI
dd (R9800XT shl 16)+VID_ATI dd (R9800XT shl 16)+VID_ATI
dd 0 ;terminator dd 0 ;terminator
version dd 0x00040004 version dd (5 shl 16) or (API_VERSION and 0xFFFF)
sz_ati_srv db 'HWCURSOR',0 sz_ati_srv db 'HWCURSOR',0

View File

@ -257,9 +257,9 @@ end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0; OS_BASE equ 0x80000000
SLOT_BASE equ OS_BASE+0x0080000 SLOT_BASE equ OS_BASE+0x0080000
new_app_base equ 0x80000000 new_app_base equ 0
public START public START
public service_proc public service_proc
@ -391,7 +391,6 @@ proc service_proc stdcall, ioctl:dword
cmp eax, DEV_GET_MASTERVOL cmp eax, DEV_GET_MASTERVOL
jne @F jne @F
mov ebx, [edi+output] mov ebx, [edi+output]
add ebx, new_app_base
stdcall get_master_vol, ebx stdcall get_master_vol, ebx
ret ret
;@@: ;@@:

View File

@ -10,6 +10,10 @@
format MS COFF format MS COFF
API_VERSION equ 0x01000100
SOUND_VERSION equ API_VERSION
include 'proc32.inc' include 'proc32.inc'
include 'main.inc' include 'main.inc'
include 'imports.inc' include 'imports.inc'
@ -22,9 +26,10 @@ FORCE_MMX_128 equ 0 ;integer sse2 extensions
DEBUG equ 1 DEBUG equ 1
OS_BASE equ 0 OS_BASE equ 0x80000000
new_app_base equ 0x80000000 SLOT_BASE equ (OS_BASE+0x0080000)
SLOT_BASE equ OS_BASE+0x0080000 TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_TASK equ (OS_BASE+0x0003000)
CAPS_SSE2 equ 26 CAPS_SSE2 equ 26
PG_SW equ 0x003 PG_SW equ 0x003
@ -159,8 +164,10 @@ proc service_proc stdcall, ioctl:dword
cmp eax, SRV_GETVERSION cmp eax, SRV_GETVERSION
jne @F jne @F
mov eax, [edi+output] mov eax, [edi+output]
cmp [edi+out_size], 4
jne .fail
mov eax, [eax] mov eax, [eax]
mov [eax+new_app_base], dword SOUND_VERSION mov [eax], dword SOUND_VERSION
xor eax, eax xor eax, eax
ret ret
@@: @@:
@ -172,7 +179,7 @@ proc service_proc stdcall, ioctl:dword
pop edi pop edi
mov ecx, [edi+output] mov ecx, [edi+output]
mov ecx, [ecx] mov ecx, [ecx]
mov [ecx+new_app_base], ebx mov [ecx], ebx
ret ret
@@: @@:
mov ebx, [edi+input] mov ebx, [edi+input]
@ -201,7 +208,7 @@ proc service_proc stdcall, ioctl:dword
movzx eax, word [edx+STREAM.format] movzx eax, word [edx+STREAM.format]
mov ecx, [edi+output] mov ecx, [edi+output]
mov ecx, [ecx] mov ecx, [ecx]
mov [ecx+new_app_base], eax mov [ecx], eax
xor eax, eax xor eax, eax
ret ret
@@: @@:
@ -222,13 +229,12 @@ proc service_proc stdcall, ioctl:dword
pop edi pop edi
mov ecx, [edi+output] mov ecx, [edi+output]
mov ecx, [ecx] mov ecx, [ecx]
mov [ecx+new_app_base], ebx mov [ecx], ebx
ret ret
@@: @@:
cmp eax, SND_SETBUFF cmp eax, SND_SETBUFF
jne @F jne @F
mov eax, [ebx+4] mov eax, [ebx+4]
add eax, new_app_base
stdcall set_buffer, [ebx],eax,[ebx+8],[ebx+12] stdcall set_buffer, [ebx],eax,[ebx+8],[ebx+12]
ret ret
@@: @@:
@ -243,8 +249,6 @@ proc service_proc stdcall, ioctl:dword
mov eax, [edi+output] mov eax, [edi+output]
mov ecx, [eax] mov ecx, [eax]
mov eax, [eax+4] mov eax, [eax+4]
add ecx, new_app_base
add eax, new_app_base
stdcall GetBufferVol,[ebx],ecx,eax stdcall GetBufferVol,[ebx],ecx,eax
ret ret
@@: @@:
@ -258,7 +262,7 @@ proc service_proc stdcall, ioctl:dword
mov eax, [edx+STREAM.pan] mov eax, [edx+STREAM.pan]
mov ebx, [edi+output] mov ebx, [edi+output]
mov ebx, [ebx] mov ebx, [ebx]
mov [ebx+new_app_base], eax mov [ebx], eax
xor eax, eax xor eax, eax
ret ret
@@: @@:
@ -266,7 +270,6 @@ proc service_proc stdcall, ioctl:dword
jne @F jne @F
mov eax, [ebx+4] mov eax, [ebx+4]
add eax, new_app_base
stdcall wave_out, [ebx],eax,[ebx+8] stdcall wave_out, [ebx],eax,[ebx+8]
ret ret
@@: @@:
@ -287,7 +290,7 @@ proc service_proc stdcall, ioctl:dword
mov eax, [edx+STREAM.in_size] mov eax, [edx+STREAM.in_size]
mov ecx, [edi+output] mov ecx, [edi+output]
mov ecx, [ecx] mov ecx, [ecx]
mov [ecx+new_app_base], eax mov [ecx], eax
xor eax, eax xor eax, eax
ret ret
@@: @@:
@ -303,10 +306,6 @@ restore inp_size
restore output restore output
restore out_size restore out_size
TASK_COUNT equ 0x0003004
CURRENT_TASK equ 0x0003000
align 4 align 4
proc CreateBuffer stdcall, format:dword, size:dword proc CreateBuffer stdcall, format:dword, size:dword
locals locals
@ -377,17 +376,17 @@ proc CreateBuffer stdcall, format:dword, size:dword
; ring and waveout ; ring and waveout
mov eax, 0x10000 mov ebx, 0x10000
test [format], PCM_RING test [format], PCM_RING
jz .waveout jz .waveout
mov eax, [eax+STREAM.r_size] mov ebx, [eax+STREAM.r_size]
add eax, 4095 add ebx, 4095
and eax, -4096 and ebx, -4096
add eax, eax add ebx, ebx
.waveout: .waveout:
mov [ring_size], eax mov [ring_size], ebx
mov ebx, eax mov eax, ebx
shr ebx, 12 shr ebx, 12
mov [ring_pages], ebx mov [ring_pages], ebx
@ -648,8 +647,8 @@ proc wave_out stdcall, str:dword,src:dword,size:dword
test esi, esi test esi, esi
jz .fail jz .fail
cmp esi, new_app_base cmp esi, OS_BASE
jb .fail ja .fail
mov [state_saved], 0 mov [state_saved], 0
@ -1252,7 +1251,7 @@ vol_min dd 0x0000D8F0,0x0000D8F0
pan_max dd 0x00002710,0x00002710 pan_max dd 0x00002710,0x00002710
;stream_map dd 0xFFFF ; 16 ;stream_map dd 0xFFFF ; 16
version dd (4 shl 16) or (SOUND_VERSION and 0xFFFF) version dd (5 shl 16) or (SOUND_VERSION and 0xFFFF)
szInfinity db 'INFINITY',0 szInfinity db 'INFINITY',0
szSound db 'SOUND',0 szSound db 'SOUND',0
@ -1284,3 +1283,8 @@ mix_2_core rd 1
mix_3_core rd 1 mix_3_core rd 1
mix_4_core rd 1 mix_4_core rd 1

View File

@ -8,11 +8,9 @@
; (C) copyright Serge 2006-2007 ; (C) copyright Serge 2006-2007
; email: infinity_sound@mail.ru ; email: infinity_sound@mail.ru
SOUND_VERSION equ 0x01000100
PLAY_SYNC equ 0x80000000 PLAY_SYNC equ 0x80000000
PCM_ALL equ 0 PCM_ALL equ 0
PCM_OUT equ 0x08000000 PCM_OUT equ 0x08000000

View File

@ -9,6 +9,8 @@
format MS COFF format MS COFF
API_VERSION equ 0 ;debug
include 'proc32.inc' include 'proc32.inc'
include 'imports.inc' include 'imports.inc'
@ -33,11 +35,13 @@ public START
public service_proc public service_proc
public version public version
DEBUG equ 1 DEBUG equ 1
DRV_ENTRY equ 1 DRV_ENTRY equ 1
DRV_EXIT equ -1 DRV_EXIT equ -1
STRIDE equ 4 ;size of row in devices table STRIDE equ 4 ;size of row in devices table
SRV_GETVERSION equ 0
section '.flat' code readable align 16 section '.flat' code readable align 16
@ -53,7 +57,7 @@ proc START stdcall, state:dword
end if end if
stdcall RegService, my_service, service_proc stdcall RegService, my_service, service_proc
ret ret
.fail: .fail:
.exit: .exit:
xor eax, eax xor eax, eax
@ -70,11 +74,21 @@ out_size equ IOCTL.out_size
align 4 align 4
proc service_proc stdcall, ioctl:dword proc service_proc stdcall, ioctl:dword
; mov edi, [ioctl] mov ebx, [ioctl]
; mov eax, [edi+io_code] mov eax, [ebx+io_code]
cmp eax, SRV_GETVERSION
jne @F
xor eax, eax mov eax, [ebx+output]
ret cmp [ebx+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
.fail:
or eax, -1
ret
endp endp
restore handle restore handle
@ -86,70 +100,70 @@ restore out_size
align 4 align 4
proc detect proc detect
locals locals
last_bus dd ? last_bus dd ?
endl endl
xor eax, eax xor eax, eax
mov [bus], eax mov [bus], eax
inc eax inc eax
call PciApi call PciApi
cmp eax, -1 cmp eax, -1
je .err je .err
mov [last_bus], eax mov [last_bus], eax
.next_bus: .next_bus:
and [devfn], 0 and [devfn], 0
.next_dev: .next_dev:
stdcall PciRead32, [bus], [devfn], dword 0 stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax test eax, eax
jz .next jz .next
cmp eax, -1 cmp eax, -1
je .next je .next
mov edi, devices mov edi, devices
@@: @@:
mov ebx, [edi] mov ebx, [edi]
test ebx, ebx test ebx, ebx
jz .next jz .next
cmp eax, ebx
je .found
cmp eax, ebx
je .found
add edi, STRIDE add edi, STRIDE
jmp @B jmp @B
.next:
.next: inc [devfn] inc [devfn]
cmp [devfn], 256 cmp [devfn], 256
jb .next_dev jb .next_dev
mov eax, [bus] mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
xor eax, eax
inc eax inc eax
ret mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
xor eax, eax
inc eax
ret
.err: .err:
xor eax, eax xor eax, eax
ret ret
endp endp
DEVICE_ID equ 1234; pci device id
;DEVICE_ID equ ; pci device id VENDOR_ID equ 5678; device vendor id
;VENDOR_ID equ ; device vendor id
;all initialized data place here ;all initialized data place here
align 4 align 4
devices dd (DEVICE_ID shl 16)+VENDOR_ID devices dd (DEVICE_ID shl 16)+VENDOR_ID
dd 0 ;terminator dd 0 ;terminator
version dd 0x00030003 version dd (5 shl 16) or (API_VERSION and 0xFFFF)
my_service db 'MY_SERVICE',0 ;max 16 chars include zero my_service db 'MY_SERVICE',0 ;max 16 chars include zero

View File

@ -10,6 +10,8 @@ format MS COFF
include 'proc32.inc' include 'proc32.inc'
include 'imports.inc' include 'imports.inc'
API_VERSION equ 0x01000100
DEBUG equ 1 DEBUG equ 1
CPU_FREQ equ 2000d ;cpu freq in MHz CPU_FREQ equ 2000d ;cpu freq in MHz
@ -90,7 +92,7 @@ CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable
CODEC_REG_POWERDOWN equ 0x26 CODEC_REG_POWERDOWN equ 0x26
CODEC_REG_ST equ 0x26 CODEC_REG_ST equ 0x26
SRV_GETVERSION equ 0
DEV_PLAY equ 1 DEV_PLAY equ 1
DEV_STOP equ 2 DEV_STOP equ 2
DEV_CALLBACK equ 3 DEV_CALLBACK equ 3
@ -249,9 +251,8 @@ end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0; 0x80400000 OS_BASE equ 0x80000000
SLOT_BASE equ OS_BASE+0x0080000 SLOT_BASE equ OS_BASE+0x0080000
new_app_base equ 0x80000000
public START public START
public service_proc public service_proc
@ -341,6 +342,18 @@ proc service_proc stdcall, ioctl:dword
mov edi, [ioctl] mov edi, [ioctl]
mov eax, [edi+io_code] mov eax, [edi+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [edi+output]
cmp [edi+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
cmp eax, DEV_PLAY cmp eax, DEV_PLAY
jne @F jne @F
if DEBUG if DEBUG
@ -375,15 +388,14 @@ proc service_proc stdcall, ioctl:dword
cmp eax, DEV_GET_MASTERVOL cmp eax, DEV_GET_MASTERVOL
jne @F jne @F
mov ebx, [edi+output] mov ebx, [edi+output]
add ebx, new_app_base
stdcall get_master_vol, ebx stdcall get_master_vol, ebx
ret ret
@@: ;@@:
cmp eax, DEV_GET_INFO ; cmp eax, DEV_GET_INFO
jne @F ; jne @F
mov ebx, [edi+output] ; mov ebx, [edi+output]
stdcall get_dev_info, ebx ; stdcall get_dev_info, ebx
ret ; ret
@@: @@:
.fail: .fail:
or eax, -1 or eax, -1
@ -1138,7 +1150,7 @@ align 4
devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS
dd 0 dd 0
version dd 0x00040004 version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_AC db '7012 AC97 controller',13,10, 0 msg_AC db '7012 AC97 controller',13,10, 0
msg_SIS db 'Silicon Integrated Systems',13,10, 0 msg_SIS db 'Silicon Integrated Systems',13,10, 0

View File

@ -11,6 +11,8 @@ format MS COFF
include 'proc32.inc' include 'proc32.inc'
include 'imports.inc' include 'imports.inc'
API_VERSION equ 0x01000100
DEBUG equ 1 DEBUG equ 1
REMAP_IRQ equ 0 REMAP_IRQ equ 0
@ -57,6 +59,9 @@ BIT29 EQU 0x20000000
BIT30 EQU 0x40000000 BIT30 EQU 0x40000000
BIT31 EQU 0x80000000 BIT31 EQU 0x80000000
PCM_4 equ BIT20
PCM_6 equ BIT21
VID_INTEL equ 0x8086 VID_INTEL equ 0x8086
VID_NVIDIA equ 0x10DE VID_NVIDIA equ 0x10DE
@ -90,16 +95,16 @@ PCM_IN_CR_REG equ 0x0b ; PCM in Control Register
MC_IN_CR_REG equ 0x2b ; MIC in Control Register MC_IN_CR_REG equ 0x2b ; MIC in Control Register
RR equ BIT1 ; reset registers. Nukes all regs RR equ BIT1 ; reset registers. Nukes all regs
CODEC_MASTER_VOL_REG equ 0x02 CODEC_MASTER_VOL_REG equ 0x02
CODEC_AUX_VOL equ 0x04 ; CODEC_AUX_VOL equ 0x04 ;
CODEC_PCM_OUT_REG equ 18h ; PCM output volume CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume
CODEC_EXT_AUDIO_REG equ 28h ; extended audio CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio
CODEC_EXT_AUDIO_CTRL_REG equ 2ah ; extended audio control CODEC_EXT_AUDIO_CTRL_REG equ 0x2a ; extended audio control
CODEC_PCM_FRONT_DACRATE_REG equ 2ch ; PCM out sample rate CODEC_PCM_FRONT_DACRATE_REG equ 0x2c ; PCM out sample rate
CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate CODEC_PCM_SURND_DACRATE_REG equ 0x2e ; surround sound sample rate
CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate CODEC_PCM_LFE_DACRATE_REG equ 0x30 ; LFE sample rate
GLOB_CTRL equ 0x2C ; Global Control GLOB_CTRL equ 0x2C ; Global Control
CTRL_STAT equ 0x30 ; Global Status CTRL_STAT equ 0x30 ; Global Status
CTRL_CAS equ 0x34 ; Codec Access Semiphore CTRL_CAS equ 0x34 ; Codec Access Semiphore
@ -118,6 +123,7 @@ CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable
CODEC_REG_POWERDOWN equ 0x26 CODEC_REG_POWERDOWN equ 0x26
CODEC_REG_ST equ 0x26 CODEC_REG_ST equ 0x26
SRV_GETVERSION equ 0
DEV_PLAY equ 1 DEV_PLAY equ 1
DEV_STOP equ 2 DEV_STOP equ 2
DEV_CALLBACK equ 3 DEV_CALLBACK equ 3
@ -250,24 +256,24 @@ struc CODEC ;Audio Chip base class
} }
struc CTRL_INFO struc CTRL_INFO
{ .pci_cmd dd ? { .pci_cmd dd ?
.irq dd ? .irq dd ?
.glob_cntrl dd ? .glob_cntrl dd ?
.glob_sta dd ? .glob_sta dd ?
.codec_io_base dd ? .codec_io_base dd ?
.ctrl_io_base dd ? .ctrl_io_base dd ?
.codec_mem_base dd ? .codec_mem_base dd ?
.ctrl_mem_base dd ? .ctrl_mem_base dd ?
.codec_id dd ? .codec_id dd ?
} }
struc IOCTL struc IOCTL
{ .handle dd ? { .handle dd ?
.io_code dd ? .io_code dd ?
.input dd ? .input dd ?
.inp_size dd ? .inp_size dd ?
.output dd ? .output dd ?
.out_size dd ? .out_size dd ?
} }
virtual at 0 virtual at 0
@ -276,9 +282,8 @@ end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0; OS_BASE equ 0x80000000
SLOT_BASE equ OS_BASE+0x0080000 SLOT_BASE equ OS_BASE+0x0080000
new_app_base equ 0x80000000
public START public START
public service_proc public service_proc
@ -358,6 +363,7 @@ proc START stdcall, state:dword
jnc .fail jnc .fail
stdcall AttachIntHandler, ebx, ac97_irq stdcall AttachIntHandler, ebx, ac97_irq
.reg:
stdcall RegService, sz_sound_srv, service_proc stdcall RegService, sz_sound_srv, service_proc
ret ret
.fail: .fail:
@ -385,6 +391,18 @@ proc service_proc stdcall, ioctl:dword
mov edi, [ioctl] mov edi, [ioctl]
mov eax, [edi+io_code] mov eax, [edi+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [edi+output]
cmp [edi+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
cmp eax, DEV_PLAY cmp eax, DEV_PLAY
jne @F jne @F
if DEBUG if DEBUG
@ -419,7 +437,6 @@ proc service_proc stdcall, ioctl:dword
cmp eax, DEV_GET_MASTERVOL cmp eax, DEV_GET_MASTERVOL
jne @F jne @F
mov ebx, [edi+output] mov ebx, [edi+output]
add ebx, new_app_base
stdcall get_master_vol, ebx stdcall get_master_vol, ebx
ret ret
;@@: ;@@:
@ -872,6 +889,12 @@ proc init_codec
xor eax, eax ; timeout error xor eax, eax ; timeout error
ret ret
.ready: .ready:
mov eax, 2 ;force set 16-bit 2-channel PCM
mov edx, GLOB_CTRL
call [ctrl.ctrl_write32]
mov eax, 5000 ; wait 5 ms
call StallExec
call detect_codec call detect_codec
xor eax, eax xor eax, eax
@ -1357,7 +1380,8 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH
dd 0 ;terminator dd 0 ;terminator
version dd 0x00040004
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_ICH db 'Intel ICH', 13,10, 0 msg_ICH db 'Intel ICH', 13,10, 0
msg_ICH0 db 'Intel ICH0', 13,10, 0 msg_ICH0 db 'Intel ICH0', 13,10, 0
@ -1415,5 +1439,3 @@ ctrl AC_CNTRL
lpc_bus rd 1 lpc_bus rd 1
civ_val rd 1 civ_val rd 1

View File

@ -0,0 +1,972 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0
UART_VERSION equ API_VERSION
PG_SW equ 0x003
page_tabs equ 0xFDC00000 ;hack
OS_BASE equ 0x80000000
SLOT_BASE equ (OS_BASE+0x0080000)
TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_TASK equ (OS_BASE+0x0003000)
struc APPOBJ ;common object header
{
.magic dd ? ;
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
};
virtual at 0
APPOBJ APPOBJ
end virtual
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
DEBUG equ 1
DRV_ENTRY equ 1
DRV_EXIT equ -1
THR_REG equ 0; x3f8 ;transtitter/reciever
IER_REG equ 1; x3f9 ;interrupt enable
IIR_REG equ 2; x3fA ;interrupt info
LCR_REG equ 3; x3FB ;line control
MCR_REG equ 4; x3FC ;modem control
LSR_REG equ 5; x3FD ;line status
MSR_REG equ 6; x3FE ;modem status
LCR_5BIT equ 0x00
LCR_6BIT equ 0x01
LCR_7BIT equ 0x02
LCR_8BIT equ 0x03
LCR_STOP_1 equ 0x00
LCR_STOP_2 equ 0x04
LCR_PARITY equ 0x08
LCR_EVEN equ 0x10
LCR_STICK equ 0x20
LCR_BREAK equ 0x40
LCR_DLAB equ 0x80
LSR_DR equ 0x01 ;data ready
LSR_OE equ 0x02 ;overrun error
LSR_PE equ 0x04 ;parity error
LSR_FE equ 0x08 ;framing error
LSR_BI equ 0x10 ;break interrupt
LSR_THRE equ 0x20 ;transmitter holding empty
LSR_TEMT equ 0x40 ;transmitter empty
LSR_FER equ 0x80 ;FIFO error
FCR_EFIFO equ 0x01 ;enable FIFO
FCR_CRB equ 0x02 ;clear reciever FIFO
FCR_CXMIT equ 0x04 ;clear transmitter FIFO
FCR_RDY equ 0x08 ;set RXRDY and TXRDY pins
FCR_FIFO_1 equ 0x00 ;1 byte trigger
FCR_FIFO_4 equ 0x40 ;4 bytes trigger
FCR_FIFO_8 equ 0x80 ;8 bytes trigger
FCR_FIFO_14 equ 0xC0 ;14 bytes trigger
IIR_INTR equ 0x01 ;1= no interrupts
IER_RDAI equ 0x01 ;reciever data interrupt
IER_THRI equ 0x02 ;transmitter empty interrupt
IER_LSI equ 0x04 ;line status interrupt
IER_MSI equ 0x08 ;modem status interrupt
MCR_DTR equ 0x01 ;0-> DTR=1, 1-> DTR=0
MCR_RTS equ 0x02 ;0-> RTS=1, 1-> RTS=0
MCR_OUT_1 equ 0x04 ;0-> OUT1=1, 1-> OUT1=0
MCR_OUT_2 equ 0x08 ;0-> OUT2=1, 1-> OUT2=0; enable intr
MCR_LOOP equ 0x10 ;lopback mode
MSR_DCTS equ 0x01 ;delta clear to send
MSR_DDSR equ 0x02 ;delta data set redy
MSR_TERI equ 0x04 ;trailinh edge of ring
MSR_DDCD equ 0x08 ;delta carrier detect
RATE_50 equ 0
RATE_75 equ 1
RATE_110 equ 2
RATE_134 equ 3
RATE_150 equ 4
RATE_300 equ 5
RATE_600 equ 6
RATE_1200 equ 7
RATE_1800 equ 8
RATE_2000 equ 9
RATE_2400 equ 10
RATE_3600 equ 11
RATE_4800 equ 12
RATE_7200 equ 13
RATE_9600 equ 14
RATE_19200 equ 15
RATE_38400 equ 16
RATE_57600 equ 17
RATE_115200 equ 18
COM_1 equ 1
COM_2 equ 2
COM_3 equ 3
COM_4 equ 4
COM_MAX equ 2 ;only two port supported
COM_1_BASE equ 0x3F8
COM_2_BASE equ 0x2F8
COM_1_IRQ equ 4
COM_2_IRQ equ 3
UART_CLOSED equ 0
UART_TRANSMIT equ 1
UART_STOP equ 2
struc UART
{
.lock dd ?
.base dd ?
.lcr_reg dd ?
.mcr_reg dd ?
.rate dd ?
.mode dd ?
.state dd ?
.rcvr_buff dd ?
.rcvr_rp dd ?
.rcvr_wp dd ?
.rcvr_count dd ?
.rcvr_top dd ?
.xmit_buff dd ?
.xmit_rp dd ?
.xmit_wp dd ?
.xmit_count dd ?
.xmit_free dd ?
.xmit_top dd ?
}
virtual at 0
UART UART
end virtual
UART_SIZE equ 18*4
struc CONNECTION
{
.magic dd ? ;'CNCT'
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
.id dd ? ;reserved
.uart dd ? ;uart pointer
}
virtual at 0
CONNECTION CONNECTION
end virtual
CONNECTION_SIZE equ 7*4
public START
public service_proc
public version
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1
jne .stop
mov eax, UART_SIZE
call Kmalloc
test eax, eax
jz .fail
mov [com1], eax
mov edi, eax
mov ecx, UART_SIZE/4
xor eax, eax
cld
rep stosd
mov eax, [com1]
mov [eax+UART.base], COM_1_BASE
stdcall AllocKernelSpace, 32768
mov edi, [com1]
mov edx, eax
mov [edi+UART.rcvr_buff], eax
add eax, 8192
mov [edi+UART.rcvr_top], eax
add eax, 8192
mov [edi+UART.xmit_buff], eax
add eax, 8192
mov [edi+UART.xmit_top], eax
call AllocPage
test eax, eax
jz .fail
shr edx, 12
or eax, PG_SW
mov [page_tabs+edx*4], eax
mov [page_tabs+edx*4+8], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+4], eax
mov [page_tabs+edx*4+12], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+16], eax
mov [page_tabs+edx*4+24], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+20], eax
mov [page_tabs+edx*4+28], eax
mov eax, [edi+UART.rcvr_buff]
invlpg [eax]
invlpg [eax+0x1000]
invlpg [eax+0x2000]
invlpg [eax+0x3000]
invlpg [eax+0x4000]
invlpg [eax+0x5000]
invlpg [eax+0x6000]
invlpg [eax+0x7000]
mov eax, edi
call uart_reset.internal ;eax= uart
stdcall AttachIntHandler, COM_1_IRQ, com_1_isr
stdcall RegService, sz_uart_srv, service_proc
ret
.fail:
.stop:
xor eax, eax
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code
input equ IOCTL.input
inp_size equ IOCTL.inp_size
output equ IOCTL.output
out_size equ IOCTL.out_size
SRV_GETVERSION equ 0
PORT_OPEN equ 1
PORT_CLOSE equ 2
PORT_RESET equ 3
PORT_SETMODE equ 4
PORT_GETMODE equ 5
PORT_SETMCR equ 6
PORT_GETMCR equ 7
PORT_READ equ 8
PORT_WRITE equ 9
align 4
proc service_proc stdcall, ioctl:dword
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, PORT_WRITE
ja .fail
cmp eax, SRV_GETVERSION
jne @F
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword UART_VERSION
xor eax, eax
ret
@@:
cmp eax, PORT_OPEN
jne @F
cmp [ebx+out_size], 4
jne .fail
mov ebx, [ebx+input]
mov eax, [ebx]
call uart_open
mov ebx, [ioctl]
mov ebx, [ebx+output]
mov [ebx], ecx
ret
@@:
mov esi, [ebx+input] ;input buffer
mov edi, [ebx+output]
call [uart_func+eax*4]
ret
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
; param
; esi= input buffer
; +0 connection
;
; retval
; eax= error code
align 4
uart_reset:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
; set mode 2400 bod 8-bit
; disable DTR & RTS
; clear FIFO
; clear pending interrupts
;
; param
; eax= uart
align 4
.internal:
mov esi, eax
mov [eax+UART.state], UART_CLOSED
mov edx, [eax+UART.base]
add edx, MCR_REG
xor eax, eax
out dx, al ;clear DTR & RTS
mov eax, esi
mov ebx, RATE_2400
mov ecx, LCR_8BIT+LCR_STOP_1
call uart_set_mode.internal
mov edx, [esi+UART.base]
add edx, IIR_REG
mov eax,FCR_EFIFO+FCR_CRB+FCR_CXMIT+FCR_FIFO_14
out dx, al
.clear_RB:
mov edx, [esi+UART.base]
add edx, LSR_REG
in al, dx
test eax, LSR_DR
jz @F
mov edx, [esi+UART.base]
in al, dx
jmp .clear_RB
@@:
mov edx, [esi+UART.base]
add edx, IER_REG
mov eax,IER_RDAI+IER_THRI+IER_LSI
out dx, al
.clear_IIR:
mov edx, [esi+UART.base]
add edx, IIR_REG
in al, dx
test al, IIR_INTR
jnz .done
shr eax, 1
and eax, 3
jnz @F
mov edx, [esi+UART.base]
add edx, MSR_REG
in al, dx
jmp .clear_IIR
@@:
cmp eax, 1
je .clear_IIR
cmp eax, 2
jne @F
mov edx, [esi+UART.base]
in al, dx
jmp .clear_IIR
@@:
mov edx, [esi+UART.base]
add edx, LSR_REG
in al, dx
jmp .clear_IIR
.done:
mov edi, [esi+UART.rcvr_buff]
mov ecx, 8192/4
xor eax, eax
mov [esi+UART.rcvr_rp], edi
mov [esi+UART.rcvr_wp], edi
mov [esi+UART.rcvr_count], eax
cld
rep stosd
mov edi, [esi+UART.xmit_buff]
mov ecx, 8192/4
mov [esi+UART.xmit_rp], edi
mov [esi+UART.xmit_wp], edi
mov [esi+UART.xmit_count], eax
mov [esi+UART.xmit_free], 8192
rep stosd
ret ;eax= 0
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 rate
; +8 mode
;
; retval
; eax= error code
align 4
uart_set_mode:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov ecx, [esi+8]
; param
; eax= uart
; ebx= baud rate
; ecx= mode
align 4
.internal:
cmp ebx, RATE_115200
ja .fail
cmp ecx, LCR_BREAK
jae .fail
mov [eax+UART.rate], ebx
mov [eax+UART.mode], ecx
mov esi, eax
mov bx, [divisor+ebx*2]
mov edx, [esi+UART.base]
push edx
add edx, LCR_REG
in al, dx
or al, 0x80
out dx, al
pop edx
mov al, bl
out dx, al
inc dx
mov al, bh
out dx, al
add edx, LCR_REG-1
mov eax, ecx
out dx, al
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 modem control reg valie
;
; retval
; eax= error code
align 4
uart_set_mcr:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov [eax+UART.mcr_reg], ebx
mov edx, [eax+UART.base]
add edx, MCR_REG
mov al, bl
out dx, al
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; eax= port
;
; retval
; ecx= connection
; eax= error code
align 4
uart_open:
dec eax
cmp eax, COM_MAX
jae .fail
mov esi, [com1+eax*4] ;uart
push esi
.do_wait:
cmp dword [esi+UART.lock],0
je .get_lock
; call change_task
jmp .do_wait
.get_lock:
mov eax, 1
xchg eax, [esi+UART.lock]
test eax, eax
jnz .do_wait
mov eax, esi ;uart
call uart_reset.internal
mov ebx, [CURRENT_TASK]
shl ebx, 5
mov ebx, [CURRENT_TASK+ebx+4]
mov eax, CONNECTION_SIZE
call CreateObject
pop esi ;uart
test eax, eax
jz .fail
mov [eax+APPOBJ.magic], 'CNCT'
mov [eax+APPOBJ.destroy], uart_close.destroy
mov [eax+CONNECTION.uart], esi
mov ecx, eax
xor eax, eax
ret
.fail:
or eax, -1
ret
restore .uart
; param
; esi= input buffer
align 4
uart_close:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
.destroy:
push [eax+CONNECTION.uart]
call DestroyObject ;eax= object
pop eax ;eax= uart
test eax, eax
jz .fail
mov [eax+UART.state], UART_CLOSED
mov [eax+UART.lock], 0 ;release port
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; eax= uart
; ebx= baud rate
align 4
set_rate:
cmp ebx, RATE_115200
ja .fail
mov [eax+UART.rate], ebx
mov bx, [divisor+ebx*2]
mov edx, [eax+UART.base]
add edx, LCR_REG
in al, dx
push eax
or al, 0x80
out dx, al
sub edx, LCR_REG
mov al, bl
out dx, al
inc edx
mov al, bh
out dx, al
pop eax
add edx, LCR_REG-1
out dx, al
.fail:
ret
; param
; ebx= uart
align 4
transmit:
push esi
push edi
mov edx, [ebx+UART.base]
pushfd
cli
mov esi, [ebx+UART.xmit_rp]
mov ecx, [ebx+UART.xmit_count]
test ecx, ecx
je .stop
cmp ecx, 16
jbe @F
mov ecx, 16
@@:
sub [ebx+UART.xmit_count], ecx
add [ebx+UART.xmit_free], ecx
cld
@@:
lodsb
out dx, al
dec ecx
jnz @B
cmp esi,[ebx+UART.xmit_top]
jb @F
sub esi, 8192
@@:
mov [ebx+UART.xmit_rp], esi
cmp [ebx+UART.xmit_count], 0
je .stop
mov [ebx+UART.state], UART_TRANSMIT
jmp @F
.stop:
mov [ebx+UART.state], UART_STOP
@@:
popfd
pop edi
pop esi
ret
; param
; esi= input buffer
; +0 connection
; +4 dst buffer
; +8 dst size
; edi= output buffer
; +0 bytes read
; retval
; eax= error code
align 4
uart_read:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+8] ;dst size
mov ecx, [eax+UART.rcvr_count]
cmp ecx, ebx
jbe @F
mov ecx, ebx
@@:
mov [edi], ecx ;bytes read
test ecx, ecx
jz .done
push ecx
mov edi, [esi+4] ;dst
mov esi, [eax+UART.rcvr_rp]
cld
rep movsb
pop ecx
cmp esi, [eax+UART.rcvr_top]
jb @F
sub esi, 8192
@@:
mov [eax+UART.rcvr_rp], esi
sub [eax+UART.rcvr_count], ecx
.done:
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 src buffer
; +8 src size
;
; retval
; eax= error code
align 4
uart_write:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov edx, [esi+8]
; param
; eax= uart
; ebx= src
; edx= count
align 4
.internal:
mov esi, ebx
mov edi, [eax+UART.xmit_wp]
.write:
test edx, edx
jz .fail
.wait:
cmp [eax+UART.xmit_free], 0
jne .fill
cmp [eax+UART.state], UART_TRANSMIT
je .wait
mov ebx, eax
push edx
call transmit
pop edx
mov eax, ebx
jmp .write
.fill:
mov ecx, [eax+UART.xmit_free]
cmp ecx, edx
jbe @F
mov ecx, edx
@@:
push ecx
cld
rep movsb
pop ecx
sub [eax+UART.xmit_free], ecx
add [eax+UART.xmit_count], ecx
sub edx, ecx
jnz .wait
.done:
cmp edi, [eax+UART.xmit_top]
jb @F
sub edi, 8192
@@:
mov [eax+UART.xmit_wp], edi
cmp [eax+UART.state], UART_TRANSMIT
je @F
mov ebx, eax
call transmit
@@:
xor eax, eax
ret
.fail:
or eax, -1
ret
align 4
com_2_isr:
mov ebx, [com2]
jmp com_1_isr.get_info
align 4
com_1_isr:
mov ebx, [com1]
.get_info:
mov edx, [ebx+UART.base]
add edx, IIR_REG
in al, dx
test al, IIR_INTR
jnz .done
shr eax, 1
and eax, 3
call [isr_action+eax*4]
jmp .get_info
.done:
ret
align 4
isr_line:
mov edx, [ebx+UART.base]
add edx, LSR_REG
in al, dx
ret
align 4
isr_recieve:
mov esi, [ebx+UART.base]
add esi, LSR_REG
mov edi, [ebx+UART.rcvr_wp]
xor ecx, ecx
cld
.read:
mov edx, esi
in al, dx
test eax, LSR_DR
jz .done
mov edx, [ebx+UART.base]
in al, dx
stosb
inc ecx
jmp .read
.done:
cmp edi, [ebx+UART.rcvr_top]
jb @F
sub edi, 8192
@@:
mov [ebx+UART.rcvr_wp], edi
add [ebx+UART.rcvr_count], ecx
ret
align 4
isr_modem:
mov edx, [ebx+UART.base]
add edx, MSR_REG
in al, dx
ret
align 4
divisor dw 2304, 1536, 1047, 857, 768, 384
dw 192, 96, 64, 58, 48, 32
dw 24, 16, 12, 6, 3, 2, 1
align 4
uart_func dd 0 ;SRV_GETVERSION
dd 0 ;PORT_OPEN
dd uart_close ;PORT_CLOSE
dd uart_reset ;PORT_RESET
dd uart_set_mode ;PORT_SETMODE
dd 0 ;PORT_GETMODE
dd uart_set_mcr ;PORT_SETMODEM
dd 0 ;PORT_GETMODEM
dd uart_read ;PORT_READ
dd uart_write ;PORT_WRITE
isr_action dd isr_modem
dd transmit
dd isr_recieve
dd isr_line
version dd (5 shl 16) or (UART_VERSION and 0xFFFF)
sz_uart_srv db 'UART',0
align 4
com1 rd 1
com2 rd 1

View File

@ -0,0 +1,736 @@
;
; MenuetOS Driver (vmode.mdr)
; Target: Vertical Refresh Rate programming and videomode changing
;
; Author: Trans <<<<<13>>>>>
; Date: 20.07.2003
;
; Version: 1.0
; OS: MenuetOS
; Compiler: FASM
;
OS_BASE equ 0x80000000
use32
macro align value { rb (value-1) - ($ + value-1) mod value }
org 0x80760000
headerstart=$
mdid db 'MDAZ' ; 4 byte id
mdhver dd 0x00 ; header version
mdcode dd MDSTART ; start of code
mdver dd 0x00000001 ; driver version (subversion*65536+version)
mdname db 'Trans VideoDriver' ; 32 bytes of full driver name
times (32-($-mdname)) db ' ' ;
headerlen=$-headerstart
times (256-headerlen) db 0 ; reserved area for future
MDSTART: ; start of driver code ( base_adr+256 bytes)
; ebx(=ecx in program):
; 1 - Get DriverInfo and Driver Initial Set
; 2 - Get Current Video Mode With Vertical Refresh Rate
; 3 - Change Video Mode
; 4 - Return at Start System Video Mode
; 5 - Change vertical and horizontal size of visible screen area
; 6 - Change Vert/Hor position visible area on screen (not complete yet)
;
; MAXF - ...
MAXF=5
;-------Main Manager-------------
pushad
cmp ebx,1
jb mdvm_00
cmp ebx,MAXF
ja mdvm_00
shl ebx,2
add ebx,mdvm_func_table
call dword [ebx]
mov [esp+28],eax
mov [esp+24],ecx
mov [esp+20],edx
mov [esp+16],ebx
popad
retn
mdvm_00:
popad
xor eax,eax
dec eax
retn
; ------Drivers Functions----------
align 4
; EBX=1 (in applications ECX=1)- Get DriverInfo and Driver Initial Set
;
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
; OUT:
;
vm_info_init:
push ecx
cmp [mdrvm],dword 0
jnz .vmii_00
call vm_safe_reg
call vm_get_initial_videomode
mov eax,[initvm]
mov [currvm],eax
call vm_search_sys_func_table
call vm_get_cur_vert_rate
mov [initrr],eax
call vm_calc_pixelclock
call vm_calc_refrate
inc [mdrvm]
.vmii_00:
pop ecx
call vm_transfer_drv_info
mov ebx,dword [refrate]
mov eax,dword [mdid] ;dword [systlb]
retn
align 4
; EBX=2 (in applications ECX=2)- Get Current Video Mode
;
; OUT: eax = X_screen*65536+Y_screen
; ebx = current vertical rate
; ecx = current video mode (number)
vm_get_cur_mode:
cmp [mdrvm],dword 0
jz .vmgcm_00
call vm_get_cur_vert_rate
mov eax,[OS_BASE+0FE00h]
mov ebx,[OS_BASE+0FE04h]
shl eax,16
add eax,ebx
add eax,00010001h
mov ebx,[refrate]
mov ecx,[currvm]
retn
.vmgcm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=3 (in applications ECX=3)- Change Video Mode
;
; IN: ecx = VertRate*65536+VideoMode
; OUT: eax = 0 if no error
;
vm_set_video_mode:
cmp [mdrvm],dword 0
jz .vmsvm_00
call vm_set_selected_mode
; xor eax,eax
retn
.vmsvm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=4 (in applications ECX=4)- Return at Start System Video Mode
;
; IN:
; OUT: eax = = 0 if no error
;
vm_restore_init_video_mode:
cmp [mdrvm],dword 0
jz .vmrivm_00
call vm_restore_reg
xor eax,eax
retn
.vmrivm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=5 (in applications ECX=5)- Change vertical and horizontal size
; of visible screen area
; IN: ecx (in app. edx) = 0/1 - -/+ horizontal size on 1 position
; = 2/3 - -/+ vertical size on 1 position (8 pixels)
; ^-^----- not complete yet
; OUT: eax = = 0 if no error
;
vm_change_screen_size:
cmp [mdrvm],dword 0
jz .vmcss_00
cmp cl,1
ja .vmcss_01
mov eax,ecx
call vm_inc_dec_width
xor eax,eax
retn
.vmcss_01:
and ecx,01h
mov eax,ecx
; call vm_inc_dec_high ; not complete yet
xor eax,eax
retn
.vmcss_00:
xor eax,eax
dec eax
retn
align 4
; EBX=6 (in applications ECX=6)- Change Vert/Hor position visible area on screen
;
; IN: ecx (in app. edx) = 0/1 - -/+ horizontal position on 1 point
; = 2/3 - -/+ vertical position on 1 pixel
; ^-^----- not complete yet
; OUT: eax = 0 if no error
;
vm_change_position_screen:
cmp [mdrvm],dword 0
jz .vmcps_00
; ...
xor eax,eax
retn
.vmcps_00:
xor eax,eax
dec eax
retn
;-----Drivers Subfunctions---------
;
; Searching i40 system functions pointer table in kernel area location
;
vm_search_sys_func_table:
push eax ; eax - current value
push ecx ; ecx - will be counter of equevalent value
push edx ; edx - last value
push esi ; esi - current address
xor ecx,ecx
mov esi,OS_BASE+010000h ; Start address of kernel location
lodsd
mov edx,eax
cld
.vmssft_00:
cmp esi,OS_BASE+30000h
ja .vmssft_03
inc ecx
lodsd
cmp edx,eax
mov edx,eax
je .vmssft_00
cmp ecx,128
ja .vmssft_02
.vmssft_01:
xor ecx,ecx
jmp .vmssft_00
.vmssft_02:
cmp edx,0
je .vmssft_01
sub esi,256*4-1
mov [systlb],esi
xor ecx,ecx
.vmssft_03_0:
inc ecx
lodsd
cmp edx,eax
mov edx,eax
jne .vmssft_03_0
mov esi,dword [systlb]
cmp cx,60
jae .vmssft_03
add esi,256*4-4
lodsb
mov edx,eax
jmp .vmssft_01
.vmssft_03:
mov [systlb],esi
pop esi
pop edx
pop ecx
pop eax
retn
; IN:
; OUT: eax= vertical rate in Hz
vm_get_cur_vert_rate:
push edx
push ebx
xor eax,eax
mov edx,eax
mov ebx,eax
mov dx,03DAh
.vmgcvt_00:
in al,dx
test al,8
jz .vmgcvt_00
.vmgcvt_01:
in al,dx
test al,8
jnz .vmgcvt_01
mov ebx,edx
rdtsc
mov edx,ebx
mov ebx,eax
.vmgcvt_02:
in al,dx
test al,8
jz .vmgcvt_02
.vmgcvt_03:
in al,dx
test al,8
jnz .vmgcvt_03
rdtsc
sub eax,ebx
mov ebx,eax
mov eax,[OS_BASE+0F600h]
xor edx,edx
div ebx
inc eax
mov [refrate],eax
pop ebx
pop edx
retn
vm_calc_pixelclock:
push ebx
push edx
xor eax,eax
mov al,[_00]
add ax,5
shl eax,3
xor ebx,ebx
mov bl,[_06]
mov bh,[_07]
and bh,00100001b
btr bx,13
jnc .vmcpc_00
or bh,2
.vmcpc_00:
xor edx,edx
mul ebx
xor edx,edx
mul [initrr]
mov [pclock],eax
pop edx
pop ebx
retn
;
; Safe of initial CRTC state
;
vm_safe_reg:
push edx
push ebx
push ecx
push edi
cli
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh
out dx,al ; Clear protection bit
dec dx
xor ecx,ecx
mov cl,19h
xor bl,bl
mov edi,CRTCreg
.vmsr_00:
mov al,bl
out dx,al
inc dx
in al,dx
dec dx
stosb
inc bl
loop .vmsr_00
sti
pop edi
pop ecx
pop ebx
pop edx
retn
;
; Restore of initial CRTC state
;
vm_restore_reg:
push eax
push ebx
push edx
push esi
mov eax,[oldX]
mov [OS_BASE+0FE00h],eax
mov eax,[oldY]
mov [OS_BASE+0FE04h],eax
mov dx,03dah
.vmrr_00:
in al,dx
test al,8
jnz .vmrr_00
.vmrr_01:
in al,dx
test al,8
jnz .vmrr_01
cli
mov dx,03c4h
mov ax,0101h
out dx,ax
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh ; Clear Protection bit
out dx,al
dec dx
xor ecx,ecx
mov cl,19h
mov esi,CRTCreg
xor bl,bl
.vmrr_02:
lodsb
mov ah,al
mov al,bl
out dx,ax
inc bl
loop .vmrr_02
sti
; call ref_screen
pop esi
pop edx
pop ecx
pop eax
retn
; Calculate of possible vertical refrash rate
; (light version of function)
vm_calc_refrate:
push ebx
push ecx
push edx
push edi
push esi
mov eax,[pclock]
xor edx,edx
mov edi,_m1
mov ebx,eax
mov ecx,(1696*1065)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(1344*804)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(1056*636)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(800*524)
div ecx
xor edx,edx
stosw
mov edi,_m1
mov esi,edi
mov ecx,5*4
.vmcrr_00:
lodsw
cmp ax,55
jb .vmcrr_01
stosw
loop .vmcrr_00
pop esi
pop edi
pop edx
pop ecx
pop ebx
retn
.vmcrr_01:
xor ax,ax
stosw
loop .vmcrr_00
pop esi
pop edi
pop edx
pop ecx
pop ebx
retn
vm_get_initial_videomode:
push eax
mov eax,dword [OS_BASE+0FE00h]
mov [oldX],eax
mov eax,dword [OS_BASE+0FE04h]
mov [oldY],eax
mov eax,dword [OS_BASE+0FE0Ch] ; initial video mode
and ax,01FFh
mov dword [initvm],eax
pop eax
retn
; IN: eax = 0/1 - -/+ 1 position of width
vm_inc_dec_width:
push ebx
push edx
mov ebx,eax
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh ; Clear Protection bit
out dx,al
dec dx
xor al,al
out dx,al
inc dx
in al,dx
dec al
cmp bl,0
jnz .vmidr_00
inc al
inc al
.vmidr_00:
out dx,al
pop edx
pop ebx
retn
;
; Copy driver info to application area
;
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
; OUT:
vm_transfer_drv_info:
push ecx
push edi
push esi
mov eax,ecx
xor ecx,ecx
mov cl,32/4
mov esi,mdname
mov edi,drvname
rep movsd
mov ecx,eax
mov eax,[mdver]
mov [drvver],eax
mov edi,[OS_BASE+3010h]
mov edi,[edi+10h]
add edi,ecx
mov esi,drvinfo
xor ecx,ecx
mov cx,512
rep movsb
pop esi
pop edi
pop ecx
retn
;
; Set selected video mode
; (light version)
;
; IN: ecx = VertRate*65536+VideoMode
;
vm_set_selected_mode:
push edx
push ecx
push esi
ror ecx,16
cmp cx,00h
je .vmssm_03
rol ecx,16
mov eax,ecx
shl eax,16
shr eax,16
mov [currvm],eax
cmp cx,112h
jne .vmssm_00
mov esi,mode0
mov ecx,639
mov edx,479
jmp .vmssm_st00
.vmssm_00:
cmp cx,115h
jne .vmssm_01
mov esi,mode1
mov ecx,799
mov edx,599
jmp .vmssm_st00
.vmssm_01:
cmp cx,118h
jne .vmssm_02
mov esi,mode2
mov ecx,1023
mov edx,767
jmp .vmssm_st00
.vmssm_02:
cmp cx,11Bh
jne .vmssm_03
mov esi,mode2
mov ecx,1279
mov edx,1023
jmp .vmssm_st00
.vmssm_03:
xor eax,eax
dec eax
pop esi
pop ecx
pop edx
retn
.vmssm_st00:
mov [OS_BASE+0FE00h],ecx
mov [OS_BASE+0FE04h],edx
cli
mov dx,03c4h
lodsw
out dx,ax
mov dx,03d4h
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh
out dx,al
dec dx
mov ecx,13
.vmssm_st01:
lodsw
out dx,ax
loop .vmssm_st01
sti
xor eax,eax
pop esi
pop ecx
pop edx
retn
;------------DATA AREA---------------
align 4
mdvm_func_table:
dd MDSTART
dd vm_info_init, vm_get_cur_mode
dd vm_set_video_mode, vm_restore_init_video_mode
dd vm_change_screen_size, vm_change_position_screen
CRTCreg:
_00 db ?
_01 db ?
_02 db ?
_03 db ?
_04 db ?
_05 db ?
_06 db ?
_07 db ?
_08 db ?
_09 db ?
_0a db ?
_0b db ?
_0c db ?
_0d db ?
_0e db ?
_0f db ?
_10 db ?
_11 db ?
_12 db ?
_13 db ?
_14 db ?
_15 db ?
_16 db ?
_17 db ?
_18 db ?
_19 db ?
align 4
oldX dd ?
oldY dd ?
initvm dd ?
currvm dd 0
refrate dd 0
initrr dd 0
systlb dd 0
pclock dd ?
mdrvm dd 0 ; 0 - not drv init yet, 1 - already drv init
drvinfo:
drvname: times 32 db ' '
drvver dd 0
times (32-($-drvver))/4 dd 0
drvmode dw 011Bh,0118h,0115h,0112h
times (64-($-drvmode))/2 dw 00h
_m1 dw 0,0,0,0,0
_m2 dw 0,0,0,0,0
_m3 dw 0,0,0,0,0
_m4 dw 0,0,0,0,0
_m5 dw 0,0,0,0,0
times (512-($-drvinfo)) db 0
drvinfoend:
;1280x1024 - 11Bh
mode3:
dw 0101h
dw 0d000h,9f01h,9f02h,9303h,0a904h,1905h,2806h,5a07h
dw 0110h,8411h,0ff12h,0ff15h,2916h
;1024x768 - 118h
mode2:
dw 0101h
dw 0a400h,7f01h,7f02h,8703h,8404h,9505h,2406h,0f507h
dw 0310h,8911h,0ff12h,0ff15h,2516h
;800x600 - 115h
mode1:
dw 0101h
dw 8000h,6301h,6302h,8303h,6a04h,1a05h,7206h,0f007h
dw 5910h,8d11h,5712h,5715h,7316h
;640x480 - 112h, 12h
mode0:
dw 0101h
dw 6000h,4f01h,4f02h,8303h,5304h,9f05h,00b06h,3e07h
dw 0ea10h,8c11h,0df12h,0df15h,0c16h
; 640x400
;mymode0:
; dw 0101h
;_0_7 dw 5f00h,4f01h,4f02h,8303h,5304h,9f05h,0BF06h,1f07h
; dw 9c10h,8e11h,8f12h,9615h,0B916h ;,4013h
; 640x800
;mymode1:
; dw 0101h
; dw 5f00h,4f01h,4f02h,8003h,5004h,9f05h,06006h,0FF07h
; dw 2d10h,8f11h,2012h,2615h,05716h ;,4013h
DRVM_END:

View File

@ -236,7 +236,7 @@ debug_beginf
pushad pushad
movzx ebx,al movzx ebx,al
mov eax,1 mov eax,1
call sys_msg_board ; call sys_msg_board
popad popad
ret ret
debug_endf debug_endf
@ -249,7 +249,7 @@ debug_beginf
movzx ebx,byte[edx] movzx ebx,byte[edx]
or bl,bl or bl,bl
jz .l2 jz .l2
call sys_msg_board ; call sys_msg_board
inc edx inc edx
jmp .l1 jmp .l1
.l2: ret .l2: ret

View File

@ -1,12 +1,12 @@
$Revision$ $Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; FAT12.INC ;; ;; FAT12.INC ;;
;; (C) 2005 Mario79, License: GPL ;; ;; (C) 2005 Mario79, License: GPL ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
n_sector dd 0 ; temporary save for sector value n_sector dd 0 ; temporary save for sector value
@ -1125,7 +1125,7 @@ fd_prev_prev_sector dd ?
endg endg
flp_root_next: flp_root_next:
cmp edi, 0xD200-0x20 cmp edi, OS_BASE+0xD200-0x20
jae @f jae @f
add edi, 0x20 add edi, 0x20
ret ; CF=0 ret ; CF=0
@ -1172,7 +1172,7 @@ flp_rootmem_extend_dir:
ret ret
flp_notroot_next: flp_notroot_next:
cmp edi, 0xD200-0x20 cmp edi, OS_BASE+0xD200-0x20
jae flp_notroot_next_sector jae flp_notroot_next_sector
add edi, 0x20 add edi, 0x20
ret ; CF=0 ret ; CF=0
@ -1223,7 +1223,7 @@ flp_notroot_end_write:
popa popa
ret ret
flp_notroot_next_write: flp_notroot_next_write:
cmp edi, 0xD200 cmp edi, OS_BASE+0xD200
jae @f jae @f
ret ret
@@: @@:
@ -1464,7 +1464,7 @@ fs_FloppyReadFolder:
cmp byte [edi+11], 0xF cmp byte [edi+11], 0xF
jnz .do_bdfe jnz .do_bdfe
add edi, 0x20 add edi, 0x20
cmp edi, 0xD200 cmp edi, OS_BASE+0xD200
jb .do_bdfe jb .do_bdfe
pop eax pop eax
inc eax inc eax
@ -1496,7 +1496,7 @@ fs_FloppyReadFolder:
call fat_entry_to_bdfe call fat_entry_to_bdfe
.l2: .l2:
add edi, 0x20 add edi, 0x20
cmp edi, 0xD200 cmp edi, OS_BASE+0xD200
jb .l1 jb .l1
pop eax pop eax
inc eax inc eax
@ -1895,7 +1895,10 @@ fs_FloppyRewrite:
jnz .ret jnz .ret
dec edi dec edi
dec edi dec edi
lea eax, [edi-(FLOPPY_FAT)]
mov eax, edi
sub eax, FLOPPY_FAT
shr eax, 1 ; eax = cluster shr eax, 1 ; eax = cluster
mov word [edi], 0xFFF ; mark as last cluster mov word [edi], 0xFFF ; mark as last cluster
xchg edi, [esp+4] xchg edi, [esp+4]
@ -2576,7 +2579,7 @@ fs_FloppyExecute:
mov ebx, [ebx+4] mov ebx, [ebx+4]
test ebx, ebx test ebx, ebx
jz @f jz @f
add ebx, std_application_base_address ; add ebx, std_application_base_address
@@: @@:
;---------------------------------------------------------------- ;----------------------------------------------------------------

View File

@ -1,48 +1,48 @@
$Revision$ $Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; FAT32.INC ;; ;; FAT32.INC ;;
;; ;; ;; ;;
;; FAT16/32 functions for KolibriOS ;; ;; FAT16/32 functions for KolibriOS ;;
;; ;; ;; ;;
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;; ;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
;; ;; ;; ;;
;; See file COPYING for details ;; ;; See file COPYING for details ;;
;; 04.02.2007 LFN create folder - diamond ;; ;; 04.02.2007 LFN create folder - diamond ;;
;; 08.10.2006 LFN delete file/folder - diamond ;; ;; 08.10.2006 LFN delete file/folder - diamond ;;
;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;; ;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;;
;; 17.08.2006 LFN write/append to file - diamond ;; ;; 17.08.2006 LFN write/append to file - diamond ;;
;; 23.06.2006 LFN start application - diamond ;; ;; 23.06.2006 LFN start application - diamond ;;
;; 15.06.2006 LFN get/set file/folder info - diamond ;; ;; 15.06.2006 LFN get/set file/folder info - diamond ;;
;; 27.05.2006 LFN create/rewrite file - diamond ;; ;; 27.05.2006 LFN create/rewrite file - diamond ;;
;; 04.05.2006 LFN read folder - diamond ;; ;; 04.05.2006 LFN read folder - diamond ;;
;; 29.04.2006 Elimination of hangup after the ;; ;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout - Mario79 ;; ;; expiration hd_wait_timeout - Mario79 ;;
;; 23.04.2006 LFN read file - diamond ;; ;; 23.04.2006 LFN read file - diamond ;;
;; 28.01.2006 find all Fat16/32 partition in all input point ;; ;; 28.01.2006 find all Fat16/32 partition in all input point ;;
;; to MBR, see file part_set.inc - Mario79 ;; ;; to MBR, see file part_set.inc - Mario79 ;;
;; 15.01.2005 get file size/attr/date, file_append - ATV ;; ;; 15.01.2005 get file size/attr/date, file_append - ATV ;;
;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;; ;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;;
;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;; ;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;;
;; 23.11.2004 don't allow overwrite dir with file - ATV ;; ;; 23.11.2004 don't allow overwrite dir with file - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;; ;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 17.11.2004 set_FAT/get_FAT and disk cache rewritten - ATV ;; ;; 17.11.2004 set_FAT/get_FAT and disk cache rewritten - ATV ;;
;; 10.11.2004 removedir clear whole directory structure - ATV ;; ;; 10.11.2004 removedir clear whole directory structure - ATV ;;
;; 08.11.2004 rename - ATV ;; ;; 08.11.2004 rename - ATV ;;
;; 30.10.2004 file_read return also dirsize in bytes - ATV ;; ;; 30.10.2004 file_read return also dirsize in bytes - ATV ;;
;; 20.10.2004 Makedir/Removedir - ATV ;; ;; 20.10.2004 Makedir/Removedir - ATV ;;
;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;; ;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;;
;; 06.9.2004 Fix free space by Mario79 added - MH ;; ;; 06.9.2004 Fix free space by Mario79 added - MH ;;
;; 24.5.2004 Write back buffer for File_write -VT ;; ;; 24.5.2004 Write back buffer for File_write -VT ;;
;; 20.5.2004 File_read function to work with syscall 58 - VT ;; ;; 20.5.2004 File_read function to work with syscall 58 - VT ;;
;; 30.3.2004 Error parameters at function return - VT ;; ;; 30.3.2004 Error parameters at function return - VT ;;
;; 01.5.2002 Bugfix in device write - VT ;; ;; 01.5.2002 Bugfix in device write - VT ;;
;; 20.5.2002 Hd status check - VT ;; ;; 20.5.2002 Hd status check - VT ;;
;; 29.6.2002 Improved fat32 verification - VT ;; ;; 29.6.2002 Improved fat32 verification - VT ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00 cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00
@ -3267,7 +3267,7 @@ fs_HdExecute:
mov ebx, [ebx+4] mov ebx, [ebx+4]
test ebx, ebx test ebx, ebx
jz @f jz @f
add ebx, std_application_base_address ; add ebx, std_application_base_address
@@: @@:
;---------------------------------------------------------------- ;----------------------------------------------------------------

View File

@ -1,21 +1,21 @@
$Revision$ $Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; ;; ;; ;;
;; System service for filesystem call ;; ;; System service for filesystem call ;;
;; (C) 2004 Ville Turjanmaa, License: GPL ;; ;; (C) 2004 Ville Turjanmaa, License: GPL ;;
;; 29.04.2006 Elimination of hangup after the ;; ;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout (for LBA) - Mario79 ;; ;; expiration hd_wait_timeout (for LBA) - Mario79 ;;
;; 15.01.2005 get file size/attr/date, ;; ;; 15.01.2005 get file size/attr/date, ;;
;; file_append (only for hd) - ATV ;; ;; file_append (only for hd) - ATV ;;
;; 23.11.2004 test if hd/partition is set - ATV ;; ;; 23.11.2004 test if hd/partition is set - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;; ;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;; ;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;;
;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;; ;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iglobal iglobal
@ -86,7 +86,7 @@ file_system:
; \end{diamond}[18.03.2006] ; \end{diamond}[18.03.2006]
; Extract parameters ; Extract parameters
add eax, std_application_base_address ; abs start of info block ; add eax, std_application_base_address ; abs start of info block
cmp dword [eax+0],15 ; GET_DISK_INFO cmp dword [eax+0],15 ; GET_DISK_INFO
je fs_info je fs_info
@ -97,7 +97,7 @@ file_system:
cmp dword [eax+0],1 cmp dword [eax+0],1
jnz .usual_check jnz .usual_check
mov ebx,[eax+12] mov ebx,[eax+12]
add ebx,std_application_base_address ; add ebx,std_application_base_address
mov ecx,[eax+8] mov ecx,[eax+8]
call check_region call check_region
test eax,eax test eax,eax
@ -120,7 +120,7 @@ endg
shl ecx,9 shl ecx,9
.small_size: .small_size:
mov ebx,[eax+12] mov ebx,[eax+12]
add ebx,std_application_base_address ; add ebx,std_application_base_address
call check_region call check_region
test eax,eax test eax,eax
jz .error_output jz .error_output
@ -148,7 +148,7 @@ endg
; \end{diamond}[18.03.2006] ; \end{diamond}[18.03.2006]
mov esi,dir0 mov esi,dir0
mov edi,[eax+12] mov edi,[eax+12]
add edi,std_application_base_address ; add edi,std_application_base_address
mov ecx,11 mov ecx,11
push ecx push ecx
; cld ; already is ; cld ; already is
@ -202,12 +202,12 @@ endg
push dword [eax+4] ; 512 block number to read push dword [eax+4] ; 512 block number to read
push dword [eax+8] ; bytes to write/append or 512 blocks to read push dword [eax+8] ; bytes to write/append or 512 blocks to read
mov ebx,[eax+12] mov ebx,[eax+12]
add ebx,std_application_base_address ; add ebx,std_application_base_address
push ebx ; abs start of return/save area push ebx ; abs start of return/save area
lea esi,[eax+20] ; abs start of dir + filename lea esi,[eax+20] ; abs start of dir + filename
mov edi,[eax+16] mov edi,[eax+16]
add edi,std_application_base_address ; abs start of work area ; add edi,std_application_base_address ; abs start of work area
call expand_pathz call expand_pathz

View File

@ -93,7 +93,7 @@ file_system_lfn:
; 8 : delete file ; 8 : delete file
; 9 : create directory ; 9 : create directory
add eax, std_application_base_address ; add eax, std_application_base_address
; parse file name ; parse file name
xchg ebx, eax xchg ebx, eax
lea esi, [ebx+20] lea esi, [ebx+20]
@ -102,7 +102,7 @@ file_system_lfn:
test al, al test al, al
jnz @f jnz @f
mov esi, [esi] mov esi, [esi]
add esi, std_application_base_address ; add esi, std_application_base_address
mov ebp, esi mov ebp, esi
lodsb lodsb
@@: @@:
@ -112,7 +112,7 @@ file_system_lfn:
mov ebx, [ebx+8] mov ebx, [ebx+8]
test ebx, ebx test ebx, ebx
jz .l1 jz .l1
add ebx, new_app_base ; add ebx, new_app_base
.l1: .l1:
call fs_execute ; ebp, ebx, edx call fs_execute ; ebp, ebx, edx
mov [esp+36], eax mov [esp+36], eax
@ -157,7 +157,7 @@ file_system_lfn:
xor eax, eax xor eax, eax
mov ebp, [ebx+12] mov ebp, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
add edx, std_application_base_address ; add edx, std_application_base_address
push dword [ebx+4] ; first block push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags mov ebx, [ebx+8] ; flags
mov esi, [edi+4] mov esi, [edi+4]
@ -239,7 +239,7 @@ file_system_lfn:
mov esi, virtual_root_query mov esi, virtual_root_query
mov ebp, [ebx+12] mov ebp, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
add edx, std_application_base_address ; add edx, std_application_base_address
push dword [ebx+4] ; first block push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags mov ebx, [ebx+8] ; flags
xor eax, eax xor eax, eax
@ -348,7 +348,7 @@ fs_OnRamdisk:
jae .not_impl jae .not_impl
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
add edx, std_application_base_address ; add edx, std_application_base_address
add ebx, 4 add ebx, 4
call dword [fs_RamdiskServices + eax*4] call dword [fs_RamdiskServices + eax*4]
mov [esp+36], eax mov [esp+36], eax
@ -385,7 +385,7 @@ fs_OnFloppy:
mov [flp_number], cl mov [flp_number], cl
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
add edx, std_application_base_address ; add edx, std_application_base_address
add ebx, 4 add ebx, 4
call dword [fs_FloppyServices + eax*4] call dword [fs_FloppyServices + eax*4]
and [flp_status], 0 and [flp_status], 0
@ -449,7 +449,7 @@ fs_OnHd:
pop esi ebx pop esi ebx
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
add edx, std_application_base_address ; add edx, std_application_base_address
mov eax, [ebx] mov eax, [ebx]
cmp eax, fs_NumHdServices cmp eax, fs_NumHdServices
jae .not_impl jae .not_impl
@ -525,7 +525,7 @@ fs_OnCd:
@@: @@:
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
add edx, std_application_base_address ; add edx, std_application_base_address
mov eax, [ebx] mov eax, [ebx]
cmp eax,fs_NumCdServices cmp eax,fs_NumCdServices
jae .not_impl jae .not_impl

View File

@ -506,7 +506,7 @@ fs_CdExecute:
mov ebx, [ebx+4] mov ebx, [ebx+4]
test ebx, ebx test ebx, ebx
jz @f jz @f
add ebx, std_application_base_address ; add ebx, std_application_base_address
@@: @@:
;---------------------------------------------------------------- ;----------------------------------------------------------------

View File

@ -172,16 +172,15 @@ button_dececx:
sys_button: sys_button:
push edi push edi
mov edi,[CURRENT_TASK] mov edi,[current_slot]
shl edi,8
rol eax,16 rol eax,16
add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] add ax,word[edi+APPDATA.wnd_clientbox.left]
rol eax,16 rol eax,16
rol ebx,16 rol ebx,16
add bx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] add bx,word[edi+APPDATA.wnd_clientbox.top]
rol ebx,16 rol ebx,16
pop edi pop edi
.forced: .forced:
test ecx,0x80000000 test ecx,0x80000000
jnz remove_button jnz remove_button
@ -228,7 +227,7 @@ sys_button:
pop edx pop edx
and edx, 0xFFFF and edx, 0xFFFF
.newline: .newline:
call button_dececx call button_dececx
push edi push edi
xor edi, edi xor edi, edi
@ -241,7 +240,7 @@ sys_button:
call drawbuttonframes call drawbuttonframes
button_no_draw: button_no_draw:
and ecx,0xffff and ecx,0xffff
@ -276,7 +275,7 @@ sys_button:
mov bx,[esp+8+0] mov bx,[esp+8+0]
mov [eax],bx mov [eax],bx
noaddbutt: noaddbutt:
pop edx pop edx
pop ecx pop ecx
@ -292,14 +291,14 @@ remove_button:
and ecx,0x7fffffff and ecx,0x7fffffff
rnewba2: rnewba2:
mov edi,[BTN_ADDR] mov edi,[BTN_ADDR]
mov eax,edi mov eax,edi
movzx ebx,word [edi] movzx ebx,word [edi]
inc bx inc bx
rnewba: rnewba:
dec bx dec bx
jz rnmba jz rnmba
@ -325,7 +324,7 @@ remove_button:
jmp rnewba2 jmp rnewba2
rnmba: rnmba:
ret ret
@ -336,17 +335,17 @@ find_pressed_button_frames:
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+ WDATA.box.left] ; window x start mov ecx, [ebx+ WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start movzx edx,word [eax+4] ; button x start
add ecx,edx add ecx,edx
push ecx push ecx
mov dx,[eax+6] ; button x size mov dx,[eax+6] ; button x size
add cx,dx add cx,dx
mov esi,ecx mov esi,ecx
inc esi inc esi
mov ecx, [ebx+WDATA.box.top] ; window y start mov ecx, [ebx+WDATA.box.top] ; window y start
mov dx,[eax+8] ; button y start mov dx,[eax+8] ; button y start
add ecx,edx add ecx,edx
mov ebx,ecx mov ebx,ecx
mov dx,[eax+10] ; button y size mov dx,[eax+10] ; button y size

View File

@ -121,9 +121,8 @@ create_event:
cld cld
rep movsd rep movsd
@@: @@:
mov ecx, [CURRENT_TASK] mov ecx, [current_slot]
shl ecx,8 add ecx, APP_OBJ_OFFSET
add ecx, SLOT_BASE+APP_OBJ_OFFSET
pushfd pushfd
cli cli
@ -224,12 +223,11 @@ align 4
proc get_event_ex stdcall, p_ev:dword, timeout:dword proc get_event_ex stdcall, p_ev:dword, timeout:dword
.wait: .wait:
mov edx,[CURRENT_TASK] mov edx,[current_slot]
shl edx,8
; cmp [SLOT_BASE+edx+APPDATA.ev_count], 0 ; cmp [SLOT_BASE+edx+APPDATA.ev_count], 0
; je .switch ; je .switch
add edx, SLOT_BASE+APP_EV_OFFSET add edx, APP_EV_OFFSET
mov eax, [edx+APPOBJ.fd] mov eax, [edx+APPOBJ.fd]
cmp eax, edx cmp eax, edx
@ -307,9 +305,7 @@ wait_event:
test [eax+EVENT.state], MANUAL_RESET test [eax+EVENT.state], MANUAL_RESET
jnz .done jnz .done
mov edx,[CURRENT_TASK] mov edx,[current_slot]
shl edx,8
add edx, SLOT_BASE
pushfd pushfd
cli ;remove event from events cli ;remove event from events
@ -576,22 +572,21 @@ get_event_for_app:
xor eax, eax xor eax, eax
ret ret
no_eventoccur3: no_eventoccur3:
;mov edi,[TASK_BASE] ; mouse event ;mov edi,[TASK_BASE] ; mouse event
test [edi+TASKDATA.event_mask],dword 00100000b test [edi+TASKDATA.event_mask],dword 00100000b
jz no_mouse_event jz no_mouse_event
mov eax,[CURRENT_TASK]
shl eax,8 mov eax, [CURRENT_TASK]
shl eax, 8
test [eax+SLOT_BASE+APPDATA.event_mask],dword 00100000b test [eax+SLOT_BASE+APPDATA.event_mask],dword 00100000b
jz no_mouse_event jz no_mouse_event
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-00100000b and [eax+SLOT_BASE+APPDATA.event_mask],dword (not 00100000b)
popad popad
mov eax,6 mov eax,6
ret ret
no_mouse_event: no_mouse_event:
;mov edi,[TASK_BASE] ; DESKTOP BACKGROUND REDRAW ;mov edi,[TASK_BASE] ; DESKTOP BACKGROUND REDRAW
test [edi+TASKDATA.event_mask],dword 16 test [edi+TASKDATA.event_mask],dword 16
@ -601,39 +596,38 @@ get_event_for_app:
popad popad
mov eax,5 mov eax,5
ret ret
no_eventoccur5: no_eventoccur5:
;mov edi,[TASK_BASE] ; IPC ;mov edi,[TASK_BASE] ; IPC
test [edi+TASKDATA.event_mask],dword 01000000b test [edi+TASKDATA.event_mask],dword 01000000b
jz no_ipc jz no_ipc
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax,8 shl eax, 8
test [eax+SLOT_BASE+APPDATA.event_mask],dword 01000000b test [eax+SLOT_BASE+APPDATA.event_mask],dword 01000000b
jz no_ipc jz no_ipc
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-01000000b and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-01000000b
popad popad
mov eax,7 mov eax,7
ret ret
no_ipc: no_ipc:
;mov edi,[TASK_BASE] ; STACK ;mov edi,[TASK_BASE] ; STACK
test [edi+TASKDATA.event_mask],dword 10000000b test [edi+TASKDATA.event_mask],dword 10000000b
jz no_stack_event jz no_stack_event
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax,8 shl eax, 8
test [eax+SLOT_BASE+APPDATA.event_mask],dword 10000000b test [eax+SLOT_BASE+APPDATA.event_mask],dword 10000000b
jz no_stack_event jz no_stack_event
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-10000000b and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-10000000b
popad popad
mov eax,8 mov eax,8
ret ret
no_stack_event: no_stack_event:
test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG
jz .test_IRQ jz .test_IRQ
mov eax, [CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax, 8 shl eax, 8
test byte [eax+SLOT_BASE+APPDATA.event_mask+1], byte 1 test byte [eax+SLOT_BASE+APPDATA.event_mask+1], byte 1
jz .test_IRQ jz .test_IRQ
and byte [eax+SLOT_BASE+APPDATA.event_mask+1], not 1 and byte [eax+SLOT_BASE+APPDATA.event_mask+1], not 1

View File

@ -16,35 +16,9 @@ load_skin_file:
mov ebx,1 mov ebx,1
or ecx,-1 or ecx,-1
mov esi,12 mov esi,12
; call fileread call fileread
pushad
push eax
sub edx,std_application_base_address
mov [skin_to_load.adr],edx
;sub eax,std_application_base_address
;mov [skin_to_load.stradr],eax
mov [skin_to_load.stradr],_skin_file_default - std_application_base_address
mov eax,skin_to_load - std_application_base_address
call file_system_lfn
;call fileread
pop eax
popad
ret ret
ret
skin_to_load:
dd 0,0,0
dd 64*1024
.adr dd 0
db 0
.stradr dd 0
struct SKIN_HEADER struct SKIN_HEADER
.ident dd ? .ident dd ?
.version dd ? .version dd ?

View File

@ -11,7 +11,7 @@ $Revision$
; ;
iglobal iglobal
_skin_file_default db '/rd/1/DEFAULT.SKN',0 _skin_file_default db 'DEFAULT SKN',0
endg endg
struct SKIN_DATA struct SKIN_DATA

View File

@ -1781,18 +1781,15 @@ random_shaped_window:
test eax, eax test eax, eax
jne rsw_no_address jne rsw_no_address
mov eax,[CURRENT_TASK] mov eax,[current_slot]
shl eax,8 mov [eax+APPDATA.wnd_shape],ebx
rsw_no_address:
mov [eax+SLOT_BASE+APPDATA.wnd_shape],ebx
rsw_no_address:
cmp eax,1 cmp eax,1
jne rsw_no_scale jne rsw_no_scale
mov eax,[CURRENT_TASK] mov eax,[current_slot]
shl eax,8 mov byte [eax+APPDATA.wnd_shape_scale], bl
mov byte [eax+SLOT_BASE+APPDATA.wnd_shape_scale], bl rsw_no_scale:
rsw_no_scale:
ret ret

274
kernel/trunk/init.inc Normal file
View File

@ -0,0 +1,274 @@
$Revision$
MEM_WB equ 6 ;write-back memory
MEM_WC equ 1 ;write combined memory
MEM_UC equ 0 ;uncached memory
align 4
proc mem_test
mov eax, cr0
and eax, not (CR0_CD+CR0_NW)
or eax, CR0_CD ;disable caching
mov cr0, eax
wbinvd ;invalidate cache
xor edi, edi
mov ebx, 'TEST'
@@:
add edi, 0x100000
xchg ebx, dword [edi]
cmp dword [edi], 'TEST'
xchg ebx, dword [edi]
je @b
mov [MEM_AMOUNT-OS_BASE], edi
and eax, not (CR0_CD+CR0_NW) ;enable caching
mov cr0, eax
mov eax, edi
ret
endp
align 4
proc init_mem
mov eax, [MEM_AMOUNT-OS_BASE]
mov [pg_data.mem_amount-OS_BASE], eax
shr eax, 12
mov edx, eax
mov [pg_data.pages_count-OS_BASE], eax
shr eax, 3
mov [pg_data.pagemap_size-OS_BASE], eax
cmp edx, (OS_BASE/4096)
jbe @F
mov edx, (OS_BASE/4096)
jmp .set
@@:
cmp edx, (HEAP_MIN_SIZE/4096)
jae .set
mov edx, (HEAP_MIN_SIZE/4096)
.set:
mov [pg_data.kernel_pages-OS_BASE], edx
shr edx, 10
mov [pg_data.kernel_tables-OS_BASE], edx
xor eax, eax
mov edi, sys_pgdir-OS_BASE
mov ecx, 4096/4
cld
rep stosd
mov edx, (sys_pgdir-OS_BASE)+ 0x800; (OS_BASE shr 20)
bt [cpu_caps-OS_BASE], CAPS_PSE
jnc .no_PSE
mov ebx, cr4
or ebx, CR4_PSE
mov eax, PG_LARGE+PG_SW
bt [cpu_caps-OS_BASE], CAPS_PGE
jnc @F
or eax, PG_GLOBAL
or ebx, CR4_PGE
@@:
mov cr4, ebx
sub [pg_data.kernel_tables-OS_BASE], 1
mov [edx], eax
add eax, 0x00400000
; mov [edx+4], eax
add edx, 4
mov eax, 0x400000+PG_SW
mov ecx, (tmp_page_tab-0x400000)/4096
jmp .map_low
.no_PSE:
mov eax, PG_SW
mov ecx, tmp_page_tab/4096
.map_low:
mov edi, tmp_page_tab
@@: ;
stosd
add eax, 0x1000
dec ecx
jnz @B
mov ecx, [pg_data.kernel_tables-OS_BASE]
shl ecx, 10
xor eax, eax
rep stosd
mov ecx, [pg_data.kernel_tables-OS_BASE]
mov eax, tmp_page_tab+PG_SW
mov edi, edx
.map_kernel_tabs:
stosd
add eax, 0x1000
dec ecx
jnz .map_kernel_tabs
mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE
mov edi, (sys_pgdir-OS_BASE)
lea esi, [edi+(OS_BASE shr 20)]
lodsd
and eax, not PG_GLOBAL
stosd
lodsd
and eax, not PG_GLOBAL
stosd
lodsd
and eax, not PG_GLOBAL
stosd
ret
endp
align 4
proc init_page_map
mov edi, sys_pgmap-OS_BASE
mov ecx, ((HEAP_BASE-OS_BASE)/4096)/32 ;384/4
mov ebx, ecx
xor eax,eax
cld
rep stosd
not eax
mov ecx, [pg_data.pagemap_size-OS_BASE]
sub ecx, ebx
shr ecx, 2
rep stosd
lea edi, [sys_pgmap-OS_BASE+ebx*4] ;+384
mov edx, [pg_data.pages_count-OS_BASE]
mov ecx, [pg_data.kernel_tables-OS_BASE]
add ecx, ((HEAP_BASE-OS_BASE)/4096) and 31
sub edx, (HEAP_BASE-OS_BASE)/4096
sub edx, ecx
mov [pg_data.pages_free-OS_BASE], edx
xor eax, eax
mov ebx, ecx
shr ecx, 5
rep stosd
not eax
mov ecx, ebx
and ecx, 31
shl eax, cl
mov [edi], eax
add edi, OS_BASE
mov [page_start-OS_BASE], edi;
mov ebx, sys_pgmap
add ebx, [pg_data.pagemap_size-OS_BASE]
mov [page_end-OS_BASE], ebx
mov [pg_data.pg_mutex-OS_BASE], 0
ret
endp
align 4
proc test_cpu
locals
cpu_type dd ?
cpu_id dd ?
cpu_Intel dd ?
cpu_AMD dd ?
endl
mov [cpu_type], 0
xor eax, eax
mov [cpu_caps-OS_BASE], eax
mov [cpu_caps+4-OS_BASE], eax
pushfd
pop eax
mov ecx, eax
xor eax, 0x40000
push eax
popfd
pushfd
pop eax
xor eax, ecx
mov [cpu_type], CPU_386
jz .end_cpuid
push ecx
popfd
mov [cpu_type], CPU_486
mov eax, ecx
xor eax, 0x200000
push eax
popfd
pushfd
pop eax
xor eax, ecx
je .end_cpuid
mov [cpu_id], 1
xor eax, eax
cpuid
mov [cpu_vendor-OS_BASE], ebx
mov [cpu_vendor+4-OS_BASE], edx
mov [cpu_vendor+8-OS_BASE], ecx
cmp ebx, dword [intel_str-OS_BASE]
jne .check_AMD
cmp edx, dword [intel_str+4-OS_BASE]
jne .check_AMD
cmp ecx, dword [intel_str+8-OS_BASE]
jne .check_AMD
mov [cpu_Intel], 1
cmp eax, 1
jl .end_cpuid
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
shr eax, 8
and eax, 0x0f
ret
.end_cpuid:
mov eax, [cpu_type]
ret
.check_AMD:
cmp ebx, dword [AMD_str-OS_BASE]
jne .unknown
cmp edx, dword [AMD_str+4-OS_BASE]
jne .unknown
cmp ecx, dword [AMD_str+8-OS_BASE]
jne .unknown
mov [cpu_AMD], 1
cmp eax, 1
jl .unknown
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
shr eax, 8
and eax, 0x0f
ret
.unknown:
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
shr eax, 8
and eax, 0x0f
ret
endp

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; KERNEL16.INC ;;
;; ;;
;; Included 16 bit kernel files for MenuetOS ;;
;; ;;
;; This file is kept separate as it will be easier to ;;
;; maintain and compile with an automated SETUP program ;;
;; in the future. ;;
;; ;;
;; Copyright Ville Turjanmaa, see file COPYING for details. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;% +include
;!!!
include "boot/bootstr.inc" ; language-independent boot messages
if lang eq en
include "boot/booteng.inc" ; english system boot messages
else if lang eq ru
include "boot/bootru.inc" ; russian system boot messages
else if lang eq et
include "boot/bootet.inc" ; estonian system boot messages
else
include "boot/bootge.inc" ; german system boot messages
;!!!
end if
if lang eq et
include "boot/et.inc" ; Estonian font
else if lang eq ru
include "boot/ru.inc" ; Russian font
end if
; ñþäà äàííûå çàïèñûâàþòñÿ â 16 ðàçðÿäíîì ðåæèìå, ÷èòàþòñÿ â 32 ðàçðÿäíîì
bx_from_load: ; ñòðóêòóðà äëÿ õðàíåíèÿ ïàðàìåòðîâ- îòêóäà ãàøðóçèëèñü, áåðåòñÿ íèæå èç bx ; {SPraid}[13.03.2007]
.from_disc db 0 ; a,b,c,d - âèí÷åñòåðû, r - ðàì äèñê
.from_part db 0,0 ; # äèñêà... ñèìâîë, à íå áàéò. '1', à íå 1
org $-0x10000
include "boot/bootcode.inc" ; 16 bit system boot code
include "bus/pci/pci16.inc"
;% -include

View File

@ -1,17 +1,17 @@
$Revision$ $Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; KERNEL32.INC ;; ;; KERNEL32.INC ;;
;; ;; ;; ;;
;; Included 32 bit kernel files for MenuetOS ;; ;; Included 32 bit kernel files for MenuetOS ;;
;; ;; ;; ;;
;; This file is kept separate as it will be easier to ;; ;; This file is kept separate as it will be easier to ;;
;; maintain and compile with an automated SETUP program ;; ;; maintain and compile with an automated SETUP program ;;
;; in the future. ;; ;; in the future. ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;struc db [a] { common . db a ;struc db [a] { common . db a
@ -41,7 +41,7 @@ $Revision$
struc RECT { struc RECT {
.left dd ? .left dd ?
.top dd ? .top dd ?
.right dd ? .right dd ?
.bottom dd ? .bottom dd ?
} }
@ -51,7 +51,7 @@ end virtual
struc BOX { struc BOX {
.left dd ? .left dd ?
.top dd ? .top dd ?
.width dd ? .width dd ?
.height dd ? .height dd ?
} }
@ -60,7 +60,7 @@ virtual at 0
end virtual end virtual
; constants definition ; constants definition
WSTATE_NORMAL = 00000000b WSTATE_NORMAL = 00000000b
WSTATE_MAXIMIZED = 00000001b WSTATE_MAXIMIZED = 00000001b
WSTATE_MINIMIZED = 00000010b WSTATE_MINIMIZED = 00000010b
WSTATE_ROLLEDUP = 00000100b WSTATE_ROLLEDUP = 00000100b
@ -77,7 +77,7 @@ struc TASKDATA
.pid dd ? .pid dd ?
dw ? dw ?
.state db ? .state db ?
db ? db ?
dw ? dw ?
.wnd_number db ? .wnd_number db ?
db ? db ?
@ -111,25 +111,28 @@ struc APPDATA
.app_name db 11 dup(?) .app_name db 11 dup(?)
db 5 dup(?) db 5 dup(?)
.fpu_state dd ? ;+16 .fpu_state dd ? ;+16
.ev_count dd ? ;+20 .ev_count dd ? ;+20
.fpu_handler dd ? ;+24 .fpu_handler dd ? ;+24
.sse_handler dd ? ;+28 .sse_handler dd ? ;+28
.pl0_stack dd ? ;unused ;+32 .pl0_stack dd ? ;unused ;+32
.heap_base dd ? ;+36 .heap_base dd ? ;+36
.heap_top dd ? ;+40 .heap_top dd ? ;+40
.cursor dd ? ;+44 .cursor dd ? ;+44
.fd_ev dd ? ;+48 .fd_ev dd ? ;+48
.bk_ev dd ? ;+52 .bk_ev dd ? ;+52
.fd_obj dd ? ;+56 .fd_obj dd ? ;+56
.bk_obj dd ? ;+60 .bk_obj dd ? ;+60
.saved_esp dd ? ;+64
.io_map rd 2 ;+68
.dbg_state dd ? ;+76
db 64 dup(?) ;+64 db 48 dup(?) ;+80
.wnd_shape dd ? ;+128 .wnd_shape dd ? ;+128
.wnd_shape_scale dd ? ;+132 .wnd_shape_scale dd ? ;+132
dd ? ;+136 dd ? ;+136
.mem_size dd ? ;+140 .mem_size dd ? ;+140
.saved_box BOX .saved_box BOX
.ipc_start dd ? .ipc_start dd ?
.ipc_size dd ? .ipc_size dd ?
@ -161,7 +164,7 @@ include "core/sync.inc" ; macros for synhronization objects
include "core/sys32.inc" ; process management include "core/sys32.inc" ; process management
include "core/sched.inc" ; process scheduling include "core/sched.inc" ; process scheduling
include "core/syscall.inc" ; system call include "core/syscall.inc" ; system call
include "core/fpu.inc" ; all fpu/sse support include "core/fpu.inc" ; all fpu/sse support
include "core/memory.inc" include "core/memory.inc"
include "core/heap.inc" ; kernel and app heap include "core/heap.inc" ; kernel and app heap
include "core/malloc.inc" ; small kernel heap include "core/malloc.inc" ; small kernel heap
@ -177,14 +180,12 @@ include "gui/button.inc"
; shutdown ; shutdown
include "boot/shutdown.inc" ; shutdown or restart
; file system ; file system
include "fs/fs.inc" ; syscall include "fs/fs.inc" ; syscall
include "fs/fat32.inc" ; read / write for fat32 filesystem include "fs/fat32.inc" ; read / write for fat32 filesystem
include "fs/ntfs.inc" ; read / write for ntfs filesystem include "fs/ntfs.inc" ; read / write for ntfs filesystem
include "fs/fat12.inc" ; read / write for fat12 filesystem include "fs/fat12.inc" ; read / write for fat12 filesystem
include "blkdev/rd.inc" ; ramdisk read /write include "blkdev/rd.inc" ; ramdisk read /write
include "fs/fs_lfn.inc" ; syscall, version 2 include "fs/fs_lfn.inc" ; syscall, version 2
include "fs/iso9660.inc" ; read for iso9660 filesystem CD include "fs/iso9660.inc" ; read for iso9660 filesystem CD
@ -205,6 +206,9 @@ include "video/cursors.inc" ; cursors functions
include "network/stack.inc" include "network/stack.inc"
;include "drivers/uart.inc"
; Mouse pointer ; Mouse pointer
include "gui/mouse.inc" include "gui/mouse.inc"

View File

@ -59,7 +59,7 @@ macro IncludeAllGlobals {
IncludeIGlobals IncludeIGlobals
IncludeUGlobals IncludeUGlobals
} }
iglobal iglobal
endg endg

View File

@ -1,4 +1,3 @@
$Revision$
; ;
; MEMORY MAP ; MEMORY MAP
; ;
@ -25,7 +24,9 @@ $Revision$
; ;
; Runtime: ; Runtime:
; ;
; 0000 -> 1FFF window_data - 256 entries ; 0x00000000 -> 0x7FFFFFFF application 2Gb
; 0x80000000 -> 1FFF window_data - 256 entries
; ;
; 0000 dword x start ; 0000 dword x start
; 0004 dword y start ; 0004 dword y start
@ -120,106 +121,119 @@ $Revision$
; FFF5 byte 1 do not draw pointer ; FFF5 byte 1 do not draw pointer
; FFFF byte do not change task for 1/100 sec. ; FFFF byte do not change task for 1/100 sec.
; ;
; 10000 -> 3DBFF kernel, 32-bit run-time code (up to 183 Kb) ; 0x80010000 -> 3DBFF kernel, 32-bit run-time code (up to 183 Kb)
; 3DC00 -> 3EBFF stack at boot time (4Kb) ; 0x8003DC00 -> 3EBFF stack at boot time (4Kb)
; 3EC00 -> 3F5FF basic text font II ; 0x8003EC00 -> 3F5FF basic text font II
; 3F600 -> 3FFFF basic text font I ; 0x8003F600 -> 3FFFF basic text font I
; 40000 -> 4FFFF data of retrieved disks and partitions (Mario79) ; 0x80040000 -> 4FFFF data of retrieved disks and partitions (Mario79)
; 50000 -> 50FFF main page directory ; 0x80050000 -> 50FFF main page directory
; 50200 -> 5FFFF pages bitmap ; 0x80050200 -> 5FFFF pages bitmap
; 60000 -> 7FFFF free (128 Kb) ; 0x80060000 -> 7FFFF free (128 Kb)
; 80000 -> 8FFFF additional app info, in 256 byte steps - 256 entries ; 0x80080000 -> 8FFFF additional app info, in 256 byte steps - 256 entries
; ;
; 00 11db name of app running ; 00 11db name of app running
; 10 108db floating point unit save area ; 0x10 dword pointer to fpu save area
; 7f byte 0= no fpu saved , 1= fpu saved to 0x10 -> restore ; 0x14 dword event count
; 80 dword address of random shaped window area ; 0x18 dword user fpu exceptoins handler
; 84 byte shape area scale ; 0x1c dword user sse exceptions handler
; 88 dword free ; 20 dword PL0 stack base
; 8C dword application memory size ; 24 dword user heap base
; 90 dword window X position save ; 28 dword user heap top
; 94 dword window Y position save ; 2c dword window cursor handle
; 98 dword window X size save ; 30 dword first event in list
; 9C dword window Y size save ; 34 dword last event in list
; A0 dword IPC memory start ; 38 dword first kernel object in list
; A4 dword IPC memory size ; 3c dword last kernel object in list
; A8 dword event bits: mouse, stack,.. ; 40 dword thread esp
; AC dword 0 or debugger slot ; 44 dword io permission map page 0
; B0 dword free ; 48 dword io permission map page 1
; B4 byte keyboard mode: 0 = keymap, 1 = scancodes 4c dword debug state: 1= load debug registers
; B8 dword physical address of directory table ; 50-7F unused
; BC dword address of debug event memory
; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7
; ;
; 90000 -> 9FFFF tmp ; 80 dword address of random shaped window area
; A0000 -> AFFFF screen access area ; 84 byte shape area scale
; B0000 -> FFFFF bios rest in peace -area ; 88 dword free
; 100000 -> 27FFFF diskette image ; 8C dword application memory size
; 280000 -> 281FFF ramdisk fat ; 90 dword window X position save
; 282000 -> 283FFF floppy fat ; 94 dword window Y position save
; 98 dword window X size save
; 9C dword window Y size save
; A0 dword IPC memory start
; A4 dword IPC memory size
; A8 dword event bits: mouse, stack,..
; AC dword 0 or debugger slot
; B0 dword free
; B4 byte keyboard mode: 0 = keymap, 1 = scancodes
; B8 dword physical address of directory table
; BC dword address of debug event memory
; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7
; ;
; 284000 -> 29FFFF free (112 Kb) ; 0x80090000 -> 9FFFF tmp
; 0x800A0000 -> AFFFF screen access area
; 0x800B0000 -> FFFFF bios rest in peace -area
; 0x80100000 -> 27FFFF diskette image
; 0x80280000 -> 281FFF ramdisk fat
; 0x80282000 -> 283FFF floppy fat
; ;
; 2A0000 -> 2B00ff wav device data ; 0x80284000 -> 29FFFF free (112 Kb)
; 2C0000 -> 2C3fff button info
; ;
; 0000 word number of buttons ; 0x802A0000 -> 2B00ff wav device data
; 0x802C0000 -> 2C3fff button info
;
; 0000 word number of buttons
; first button entry at 0x10 ; first button entry at 0x10
; +0000 word process number ; +0000 word process number
; +0002 word button id number : bits 00-15 ; +0002 word button id number : bits 00-15
; +0004 word x start ; +0004 word x start
; +0006 word x size ; +0006 word x size
; +0008 word y start ; +0008 word y start
; +000A word y size ; +000A word y size
; +000C word button id number : bits 16-31 ; +000C word button id number : bits 16-31
; ;
; 2C4000 -> 2CFFFF free (48Kb) ; 0x802C4000 -> 2CFFFF free (48Kb)
; ;
; 2D0000 -> 2DFFFF reserved port area ; 0x802D0000 -> 2DFFFF reserved port area
; ;
; 0000 dword no of port areas reserved ; 0000 dword no of port areas reserved
; 0010 dword process id ; 0010 dword process id
; dword start port ; dword start port
; dword end port ; dword end port
; dword 0 ; dword 0
; ;
; 2E0000 -> 2EFFFF irq data area ; 0x802E0000 -> 2EFFFF irq data area
; 2F0000 -> 2FFFFF low memory save ; 0x802F0000 -> 2FFFFF low memory save
; ;
; 300000 -> 45FFFF background image, max 1,375 M ; 0x80300000 -> 45FFFF background image, max 1,375 M
; ;
; 460000 -> 5FFFFF display info ; 0x80460000 -> 5FFFFF display info
; ;
; 600000 -> 6FFFFF hd cache ; 0x80600000 -> 6FFFFF hd cache
; ;
; 700000 -> 71ffff tcp memory (128 kb) ; 0x80700000 -> 71ffff tcp memory 128 Kb
; 720000 -> 75ffff free (256 kb) ; 0x80720000 -> 75ffff free (256 kb)
; ;
; 760000 -> 76ffff !vrr driver ; 0x80760000 -> 76ffff !vrr driver
; 770000 -> 777fff tcp memory ( 32 kb) ; 0x80770000 -> 777fff tcp memory 32 Kb
;
; 780000 -> 987FFF TSS and IO map for (8192*8)=65536 ports
; (128+8192)*256 = 2129920 = 0x208000
;
; 988000 -> 98AFFF draw_data - 256 entries
; ;
; 0x80780000 -> 0x80782FFF draw data - 256 entries
; 00 dword draw limit - x start ; 00 dword draw limit - x start
; 04 dword draw limit - y start ; 04 dword draw limit - y start
; 08 dword draw limit - x end ; 08 dword draw limit - x end
; 0C dword draw limit - y end ; 0C dword draw limit - y end
; ;
; 0x80783F80 -> 0x80783FFF TSS 128 bytes
; ;
; 0x0098B000 -> kernel heap ; 0x80784000 -> 0x80785FFF IO map for (8192*8)=65536 ports
; ;
; 0x01FFFFFF heap min limit ; 0x80786000 -> kernel heap
; 0x7DBFFFFF heap max limit ; 0x81FFFFFF heap min limit
; 0x7DC00000 -> 0x7FBFFFFF LFB 32Mb ; 0xFDBFFFFF heap max limit
; 0x7DC00000 -> 0x7E3FFFFF application available LFB 8Mb
; 0x7E400000 -> 0x7FBFFFFF kernel LFB part 24 Mb ; 0xFDC00000 -> 0xFDFFFFFF page tables 4Mb
; 0x7FC00000 -> 0x7FFFFFFF page tables 4Mb ; 0xFE000000 -> 0xFFFFFFFF LFB 32Mb
; 0x80000000 -> 0xFFFFFFFF application 2Gb ; 0xFE000000 -> 0xFE7FFFFF application available LFB 8Mb
; 0xFE800000 -> 0xFFFFFFFF kernel LFB part 24 Mb

View File

@ -596,7 +596,7 @@ socket_read_packet:
.startcopy: .startcopy:
mov edi, ecx ; mov edi, ecx ;
add edi, std_application_base_address ; get data pointer to buffer in application ; add edi, std_application_base_address ; get data pointer to buffer in application
mov esi, ebx ; mov esi, ebx ;
add esi, SOCKETHEADERSIZE ; we dont need to copy the header add esi, SOCKETHEADERSIZE ; we dont need to copy the header

View File

@ -1,4 +1,4 @@
$Revision$
; Macroinstructions for defining and calling procedures ; Macroinstructions for defining and calling procedures
macro stdcall proc,[arg] ; directly call STDCALL procedure macro stdcall proc,[arg] ; directly call STDCALL procedure

View File

@ -1,10 +1,15 @@
$Revision$ $Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LOAD_FROM_FILE equ 0 LOAD_FROM_FILE equ 0
LOAD_FROM_MEM equ 1 LOAD_FROM_MEM equ 1
LOAD_INDIRECT equ 2 LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3 LOAD_SYSTEM equ 3
VIDEO_FREE equ 2
struc BITMAPINFOHEADER { struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD .biSize dd ? ; DWORD
@ -268,15 +273,13 @@ proc set_cursor stdcall, hcursor:dword
jne .fail jne .fail
; cmp [eax+CURSOR.size], CURSOR_SIZE ; cmp [eax+CURSOR.size], CURSOR_SIZE
; jne .fail ; jne .fail
mov ebx, [CURRENT_TASK] mov ebx, [current_slot]
shl ebx, 8 xchg eax, [ebx+APPDATA.cursor]
xchg eax, [ebx+SLOT_BASE+APPDATA.cursor]
ret ret
.fail: .fail:
mov eax, [def_cursor] mov eax, [def_cursor]
mov ebx, [CURRENT_TASK] mov ebx, [current_slot]
shl ebx, 8 xchg eax, [ebx+APPDATA.cursor]
xchg eax, [ebx+SLOT_BASE+APPDATA.cursor]
ret ret
endp endp
@ -399,12 +402,11 @@ proc delete_cursor stdcall, hcursor:dword
cmp ebx, [esi+CURSOR.pid] cmp ebx, [esi+CURSOR.pid]
jne .fail jne .fail
mov ebx, [CURRENT_TASK] mov ebx, [current_slot]
shl ebx, 8 cmp esi, [ebx+APPDATA.cursor]
cmp esi, [ebx+SLOT_BASE+APPDATA.cursor]
jne @F jne @F
mov eax, [def_cursor] mov eax, [def_cursor]
mov [ebx+SLOT_BASE+APPDATA.cursor], eax mov [ebx+APPDATA.cursor], eax
@@: @@:
mov eax, [hcursor] mov eax, [hcursor]
call [eax+APPOBJ.destroy] call [eax+APPOBJ.destroy]

View File

@ -27,7 +27,7 @@ endg
pushd [ScreenWidth] [ScreenHeight] pushd [ScreenWidth] [ScreenHeight]
popd [old_screen_height] [old_screen_width] popd [old_screen_height] [old_screen_width]
or eax,-1 ; If driver is absent then eax does not change or eax,-1 ; If driver is absent then eax does not change
call 0x760100 ; Entry point of video driver call OS_BASE+0x760100 ; Entry point of video driver
mov [esp+36],eax mov [esp+36],eax
mov [esp+24],ebx mov [esp+24],ebx
mov [esp+32],ecx mov [esp+32],ecx

View File

@ -24,15 +24,8 @@ $Revision$
mov [OS_BASE+0x760000],eax ; mov [OS_BASE+0x760000],eax ;
mov [OS_BASE+0x760100],byte 0xC3 ; Instruction RETN - driver loop mov [OS_BASE+0x760100],byte 0xC3 ; Instruction RETN - driver loop
pushad mov esi, vmode
push eax xor ebx, ebx
mov eax, vmode - std_application_base_address mov ecx, 0x8000 ; size of memory area for driver
call file_system_lfn mov edx, OS_BASE+0x760000 ; Memory position of driver
pop eax call fs_RamdiskRead
popad
; mov esi, vmode
; xor ebx, ebx
; mov ecx, 0x8000 ; size of memory area for driver
; mov edx, OS_BASE+0x760000 ; Memory position of driver
; call fs_RamdiskRead