Osinit.inc
[ Return to Browse Source Page ]
;.code
; position cursor
mov ah,02
xor bh,bh
mov dx,0500h
int 10h
; these three lines disable blinking in text mode.
; thus bit 7 of a style byte in the B800 vram denotes
; brightness of the background color instead of blinking.
mov ax,01003h
xor bl,bl
int 10h
;diskmotoroff
mov dx,03f2h
in al,dx
and al,0Fh
out dx,al
mov dl,072h
in al,dx
and al,0Fh
out dx,al
call cpudetect
call system_requirements
; from Pmsetup.inc
in al,070h ; Too small to make a seperate proc.
or al,080h ; These 3 lines mask the NMI.
out 070h,al
cli
call enable_a20
call reloc_pic
call build_gdt
.386P
xor ax,ax
mov ds,ax
lgdt pword ptr ds:[1000h] ; indirection of indirections.
mov eax,cr0
or al,1
mov cr0,eax
jmp flush
flush:
.386P
push PDA
push FLAT_DATA
pop ds
pop es
; Transfer memory
;
; It copies the PreDefined Data -> Data Segment.
; (PreDefined Data being strings and any other variables
; that made for smaller code if they were set to a certain
; value before execution. PreDefined Data is anything that
; you would NOT use "db ?" for.)
; For the UnDefined Data, (db ?'s), it sets them all to 0 so
; that all my db 0's can go here too. works nicely, as lots of
; stuff is initialized to 0. The UnDefined Data uses no disk space.
mov edi,070000h
mov esi,(00A000h+offset OS_Threshold)
add esi,offset os_code_sz
mov ecx,offset os_rdata_sz
call rmvsb
xor al,al
mov ecx,os_udata_sz
call rstsb
mov ecx,cs:[os_codestartshere]
mov edi,ecx
mov esi,(0A000h + offset OS_Threshold)
sub ecx,90000h ; 90000-ecx = loop
neg ecx ; ecx-90000 = -loop
shr ecx,2
rmvsd:
mov eax,[esi]
lea esi,[esi+4]
dec ecx
mov [edi],eax
lea edi,[edi+4]
jnz rmvsd
; Check memory size, unrealmode style
mov esi,0100000h
xor ecx,ecx
memsize_loop:
mov ax,[esi]
not ax
mov [esi],ax
mov bx,[esi]
xor bx,ax
jnz memsize_break
inc ecx
add esi,4096
jc memsize_break ; if (4 gigs detected)
jmp memsize_loop
memsize_break:
mov es:[PDA_MemSize],ecx
and ecx,0FFFFFF00h
jz memory_bad
call build_idt
lidt pword ptr cs:(idtr)
mov ax,OS_Stack
mov ss,ax
mov esp,01000h
push PDA
pop gs
mov ax,OS_Data
mov ds,ax
mov es,ax
mov fs,ax
finit
db 0eah ; Jmp Far
dw 0, OS_Code
memory_bad:
mov eax,cr0
and al,0FEh
mov cr0,eax
jmp flush2
flush2:
push cs
pop ds
mov si,offset nomemory
call realmodestring
jmp $
rstsb:
mov [edi],al
dec ecx
lea edi,[edi+1]
jnz rstsb
ret
rmvsb:
mov al,[esi]
inc esi ; the alu is actually quite underused here, so inc may be better
; than lea?
mov [edi],al
dec ecx
lea edi,[edi+1] ; the alu has just been used, and you need to preserve the
; flags anyway. so it's lea instead of inc.
jnz rmvsb
ret
nomemory db "2 Megs Ram Required.",0
CRLF equ 0Dh,0Ah
idtr dw ((256*8)-1) ; limit
dd 0800h ; linear address
include real.inc
include cpu.inc
include sysreq.inc
include pmsetup.inc
include inttbl.inc
OS_Threshold equ $
Download this file.
[ Return to Browse Source Page ]
Copyright 2000, Ed Pizzi