boot time allocator

git-svn-id: svn://kolibrios.org@841 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-07-30 08:32:24 +00:00
parent 3a719cd911
commit b2e313b0d9
5 changed files with 68 additions and 54 deletions

View File

@ -330,7 +330,9 @@ virtual at (OS_BASE+0x033CF80)
tss TSS tss TSS
end virtual end virtual
sys_pgmap equ (OS_BASE+0x033F000) LAST_PAGE equ 0x0340000
sys_pgmap equ (OS_BASE+LAST_PAGE)
twdw equ 0x3000 ;(CURRENT_TASK-window_data) twdw equ 0x3000 ;(CURRENT_TASK-window_data)

View File

@ -102,8 +102,8 @@ init_kernel_heap:
not eax not eax
rep stosd rep stosd
stdcall alloc_pages, dword 32 mov ecx, 128*1024
add eax, OS_BASE fastcall _balloc
mov [mem_block_start], mem_block_map mov [mem_block_start], mem_block_map
mov [mem_block_end], mem_block_map+512 mov [mem_block_end], mem_block_map+512

View File

@ -1306,3 +1306,14 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
endp endp
align 4
_balloc: ; gcc fastcall
mov eax, [_last_page]
add ecx, 4095
and ecx, -4096
add ecx, eax
mov [_last_page], ecx
add eax, OS_BASE
ret

View File

@ -109,6 +109,9 @@ vrr_m db 'VRR_M',0
kernel_file db 'KERNEL MNT' kernel_file db 'KERNEL MNT'
align 4 align 4
_last_page dd LAST_PAGE
;supported videomodes ;supported videomodes
mode_1280_1024_32: mode_1280_1024_32:
dw 1280,1024,32,60 dw 1280,1024,32,60

View File

@ -58,6 +58,8 @@ include 'macros.inc'
$Revision$ $Revision$
fastcall equ call
USE_COM_IRQ equ 1 ;make irq 3 and irq 4 available for PCI devices USE_COM_IRQ equ 1 ;make irq 3 and irq 4 available for PCI devices
include "proc32.inc" include "proc32.inc"
@ -320,7 +322,8 @@ init_mem:
shr eax, 3 shr eax, 3
and eax, -4 and eax, -4
mov [pg_data.pagemap_size], eax mov [pg_data.pagemap_size], eax
mov ecx, eax
fastcall _balloc
ret ret
align 4 align 4
@ -333,7 +336,9 @@ init_page_map:
cld cld
rep stosd rep stosd
mov ecx, 0x800000 ;reserve 8 Mb xchg bx, bx
mov ecx, [_last_page]
mov edx, [pg_data.pages_count] mov edx, [pg_data.pages_count]
shr ecx, 12 shr ecx, 12
sub edx, ecx sub edx, ecx
@ -395,6 +400,43 @@ high_code:
call init_mem call init_mem
mov ecx, 1280*1024
fastcall _balloc
mov [_display_data], eax
mov ecx, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \
(unpack.lc+unpack.lp)))*4
fastcall _balloc
mov [unpack.p], eax
mov ecx, (RING0_STACK_SIZE+512)
fastcall _balloc
mov [os_stack_seg], eax
lea esp, [eax+RING0_STACK_SIZE]
mov [tss._ss0], os_stack
mov [tss._esp0], esp
mov [tss._esp], esp
mov [tss._cs],os_code
mov [tss._ss],os_stack
mov [tss._ds],app_data
mov [tss._es],app_data
mov [tss._fs],app_data
mov [tss._gs],app_data
mov [tss._io],128
;Add IO access table - bit array of permitted ports
mov edi, tss._io_map_0
xor eax, eax
not eax
mov ecx, 8192/4
rep stosd ; access to 4096*8=65536 ports
mov ax,tss0
ltr ax
call init_kernel_heap ; FIXME initialize heap after pager
call init_page_map call init_page_map
@ -548,34 +590,6 @@ high_code:
call build_interrupt_table call build_interrupt_table
lidt [idtreg] lidt [idtreg]
call init_kernel_heap
stdcall alloc_pages, (RING0_STACK_SIZE+512) shr 12
add eax, OS_BASE
mov [os_stack_seg], eax
lea esp, [eax+RING0_STACK_SIZE]
mov [tss._ss0], os_stack
mov [tss._esp0], esp
mov [tss._esp], esp
mov [tss._cs],os_code
mov [tss._ss],os_stack
mov [tss._ds],app_data
mov [tss._es],app_data
mov [tss._fs],app_data
mov [tss._gs],app_data
mov [tss._io],128
;Add IO access table - bit array of permitted ports
mov edi, tss._io_map_0
xor eax, eax
not eax
mov ecx, 8192/4
rep stosd ; access to 4096*8=65536 ports
mov ax,tss0
ltr ax
mov [LFBSize], 0x800000 mov [LFBSize], 0x800000
call init_LFB call init_LFB
call init_fpu call init_fpu
@ -609,15 +623,6 @@ high_code:
add eax, ebx add eax, ebx
mov [ipc_ptab], eax mov [ipc_ptab], eax
stdcall alloc_pages, (1280*1024)/4096
add eax, OS_BASE
mov [_display_data], eax
stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \
(unpack.lc+unpack.lp)))*4
mov [unpack.p], eax
call init_events call init_events
mov eax, srv.fd-SRV_FD_OFFSET mov eax, srv.fd-SRV_FD_OFFSET
mov [srv.fd], eax mov [srv.fd], eax
@ -938,13 +943,6 @@ first_app_found:
and al,00000010b and al,00000010b
loopnz @b loopnz @b
; mov al, 0xED ; svetodiody - only for testing!
; call kb_write
; call kb_read
; mov al, 111b
; call kb_write
; call kb_read
mov al, 0xF3 ; set repeat rate & delay mov al, 0xF3 ; set repeat rate & delay
call kb_write call kb_write
; call kb_read ; call kb_read