feat: migration progressive des sources vers fasm, noyau - systeme.asm

This commit is contained in:
Nicolas Hordé 2019-07-06 10:52:53 +02:00
parent 6b14100dc5
commit d2028e1803
8 changed files with 924 additions and 779 deletions

View File

@ -1,20 +1,21 @@
struc cpu
vendor db 13 dup(0) ;Chaine 0 du fabriquant
names db 32 dup(0)
stepping db 0
models db 0
family db 0
types db 0
emodels db 0
efamily db 0
mmx db 0
mmx2 db 0
sse db 0
sse2 db 0
sse3 db 0
fpu db 0
now3d db 0
now3d2 db 0
htt db 0
apic db 0
ends cpu
struc cpu
{
.vendor db 13 dup(0) ;Chaine 0 du fabriquant
.names db 32 dup(0)
.stepping db 0
.models db 0
.family db 0
.types db 0
.emodels db 0
.efamily db 0
.mmx db 0
.mmx2 db 0
.sse db 0
.sse2 db 0
.sse3 db 0
.fpu db 0
.now3d db 0
.now3d2 db 0
.htt db 0
.apic db 0
}

View File

@ -38,13 +38,13 @@ struc entries
}
;Pour recherches
struc find
struc find files
{
.files db 13 dup (0) ;le fichier
.entryplace dw 0 ;En octet
.adressdirectory dw 0 ;En cluster
.firstsearch db 1 ;Premiere requete ?
.result entries <>
.result entries
}
struc bootinfo vendor,drivename,serialnumber

View File

@ -26,17 +26,19 @@ struc regs
;.sst7 dt 0
}
struc tuple
struc tuple off,seg
{
.off dw 0 ;adresse
.seg dw 0 ;segment
}
;union vector
;{
;.data tuple 0,0
;.content dd 0
;}
struc vector off,seg
{
.data tuple off,seg
virtual at .data
.content dd 0
end virtual
}
struc ints ;bloc interruption
{
@ -55,9 +57,11 @@ struc ints ;bloc interruption
.vector6 vector ?
.vector7 vector ?
.vector8 vector ?
.sizeof = $ - .number
}
struc mb ;Bloc de mémoire
struc mb check,isnotlast,isresident,reference,sizes,names
;Bloc de mémoire
{
.check db "NH" ;signature du bloc de mémoire.
.isnotlast db 0 ;flag indiquant le dernier bloc
@ -65,9 +69,11 @@ struc mb ;Bloc de m
.reference dw 0 ;pointeur vers le bloc parent
.sizes dw 0 ;taille du bloc en paragraphe de 16 octet
.names db 24 dup (0) ;nom du bloc
.sizeof = $ - .check
}
struc exe ;Executable COS
struc exe major
;Executable COS
{
.checks db "CE" ;signature de l'exe
.major db 1 ;N° version
@ -79,7 +85,7 @@ struc exe ;Executable COS
.starting dw 15
}
struc descriptor
struc descriptor limit_low,base_low,base_middle,dpltype,limit_high,base_high
{
.limit_low dw 0
.base_low dw 0
@ -87,6 +93,7 @@ struc descriptor
.dpltype db 0
.limit_high db 0
.base_high db 0
.sizeof = $ - .limit_low
}
free equ 0 ;Reference quand libre
@ -137,7 +144,273 @@ macro declare fonction*
dw fonction
}
macro heading versmaj*,versmin*,start*
{
header exe "CE",versmaj,versmin,0,exports,imports,0,start
}
; Macroinstructions for defining and calling procedures
macro stdcall proc,[arg] ; directly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushw arg
common
end if
call proc }
macro invoke proc,[arg] ; indirectly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushw arg
common
end if
call [proc] }
macro ccall proc,[arg] ; directly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushw arg
size@ccall = size@ccall+2
common
end if
call proc
if size@ccall
add sp,size@ccall
end if }
macro cinvoke proc,[arg] ; indirectly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushw arg
size@ccall = size@ccall+2
common
end if
call [proc]
if size@ccall
add sp,size@ccall
end if }
macro proc [args] ; define procedure
{ common
match name params, args>
\{ define@proc name,<params \} }
prologue@proc equ prologuedef
macro prologuedef procname,flag,parmbytes,localbytes,reglist
{ if parmbytes | localbytes
push bp
mov bp,sp
if localbytes
sub sp,localbytes
end if
end if
irps reg, reglist \{ push reg \} }
epilogue@proc equ epiloguedef
macro epiloguedef procname,flag,parmbytes,localbytes,reglist
{ irps reg, reglist \{ reverse pop reg \}
if parmbytes | localbytes
leave
end if
if flag and 10000b
retn
else
retn parmbytes
end if }
macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current
if used name
name:
match =stdcall args, statement \{ params equ args
flag = 11b \}
match =stdcall, statement \{ params equ
flag = 11b \}
match =c args, statement \{ params equ args
flag = 10001b \}
match =c, statement \{ params equ
flag = 10001b \}
match =params, params \{ params equ statement
flag = 0 \}
virtual at bp+4
match =uses reglist=,args, params \{ regs equ reglist
params equ args \}
match =regs =uses reglist, regs params \{ regs equ reglist
params equ \}
match =regs, regs \{ regs equ \}
match =,args, params \{ defargs@proc args \}
match =args@proc args, args@proc params \{ defargs@proc args \}
parmbytes = $ - (bp+4)
end virtual
name # % = parmbytes/2
all@vars equ
current = 0
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
macro locals
\{ virtual at bp-localbytes+current
macro label . \\{ deflocal@proc .,:, \\}
struc db [val] \\{ \common deflocal@proc .,db,val \\}
struc du [val] \\{ \common deflocal@proc .,du,val \\}
struc dw [val] \\{ \common deflocal@proc .,dw,val \\}
struc dp [val] \\{ \common deflocal@proc .,dp,val \\}
struc dd [val] \\{ \common deflocal@proc .,dd,val \\}
struc dt [val] \\{ \common deflocal@proc .,dt,val \\}
struc dq [val] \\{ \common deflocal@proc .,dq,val \\}
struc rb cnt \\{ deflocal@proc .,rb cnt, \\}
struc rw cnt \\{ deflocal@proc .,rw cnt, \\}
struc rp cnt \\{ deflocal@proc .,rp cnt, \\}
struc rd cnt \\{ deflocal@proc .,rd cnt, \\}
struc rt cnt \\{ deflocal@proc .,rt cnt, \\}
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \}
macro endl
\{ purge label
restruc db,du,dw,dp,dd,dt,dq
restruc rb,rw,rp,rd,rt,rq
current = $-(bp-localbytes)
end virtual \}
macro ret operand
\{ match any, operand \\{ retn operand \\}
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2
end if \} }
macro defargs@proc [arg]
{ common
if ~ arg eq
forward
local ..arg,current@arg
match argname:type, arg
\{ current@arg equ argname
label ..arg type
argname equ ..arg
if dqword eq type
dw ?,?,?,?,?,?,?,?
else if tbyte eq type
dw ?,?,?,?,?
else if qword eq type | pword eq type
dw ?,?,?,?
else if dword eq type
dw ?,?
else
dw ?
end if \}
match =current@arg,current@arg
\{ current@arg equ arg
arg equ ..arg
..arg dw ? \}
common
args@proc equ current@arg
forward
restore current@arg
common
end if }
macro deflocal@proc name,def,[val]
{ common
match vars, all@vars \{ all@vars equ all@vars, \}
all@vars equ all@vars name
forward
local ..var,..tmp
..var def val
match =?, val \{ ..tmp equ \}
match any =dup (=?), val \{ ..tmp equ \}
match tmp : value, ..tmp : val
\{ tmp: end virtual
initlocal@proc ..var,def value
virtual at tmp\}
common
match first rest, ..var, \{ name equ first \} }
macro initlocal@proc name,def
{ virtual at name
def
size@initlocal = $ - name
end virtual
position@initlocal = 0
while size@initlocal > position@initlocal
virtual at name
def
if size@initlocal - position@initlocal < 2
current@initlocal = 1
load byte@initlocal byte from name+position@initlocal
else if size@initlocal - position@initlocal < 4
current@initlocal = 2
load word@initlocal word from name+position@initlocal
else
current@initlocal = 4
load dword@initlocal dword from name+position@initlocal
end if
end virtual
if current@initlocal = 1
mov byte [name+position@initlocal],byte@initlocal
else if current@initlocal = 2
mov word [name+position@initlocal],word@initlocal
else
mov dword [name+position@initlocal],dword@initlocal
end if
position@initlocal = position@initlocal + current@initlocal
end while }
macro endp
{ purge ret,locals,endl
finish@proc
purge finish@proc
restore regs@proc
match all,args@proc \{ restore all \}
restore args@proc
match all,all@vars \{ restore all \} }
macro local [var]
{ common
locals
forward done@local equ
match varname[count]:vartype, var
\{ match =BYTE, vartype \\{ varname rb count
restore done@local \\}
match =WORD, vartype \\{ varname rw count
restore done@local \\}
match =DWORD, vartype \\{ varname rd count
restore done@local \\}
match =PWORD, vartype \\{ varname rp count
restore done@local \\}
match =QWORD, vartype \\{ varname rq count
restore done@local \\}
match =TBYTE, vartype \\{ varname rt count
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
rq count+count
restore done@local \\}
match , done@local \\{ virtual
varname vartype
end virtual
rb count*sizeof.\#vartype
restore done@local \\} \}
match :varname:vartype, done@local:var
\{ match =BYTE, vartype \\{ varname db ?
restore done@local \\}
match =WORD, vartype \\{ varname dw ?
restore done@local \\}
match =DWORD, vartype \\{ varname dd ?
restore done@local \\}
match =PWORD, vartype \\{ varname dp ?
restore done@local \\}
match =QWORD, vartype \\{ varname dq ?
restore done@local \\}
match =TBYTE, vartype \\{ varname dt ?
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
dq ?,?
restore done@local \\}
match , done@local \\{ varname vartype
restore done@local \\} \}
match ,done@local
\{ var
restore done@local \}
common
endl }

View File

@ -1,29 +1,31 @@
struc pcidata
vendor dw 0 ;vendor ID (read-only), FFFFh returned if requested device non-existent
device dw 0 ;device ID (read-only)
command dw 0 ;command register
status dw 0 ;status register
revision db 0 ;revision ID
interface db 0 ;programming interface
subclass db 0 ;sub-class
class db 0 ;class code
cache db 0 ;cache line size
timer db 0 ;latency timer
typed db 0 ;header type
{
.vendor dw 0 ;vendor ID (read-only), FFFFh returned if requested device non-existent
.device dw 0 ;device ID (read-only)
.command dw 0 ;command register
.status dw 0 ;status register
.revision db 0 ;revision ID
.interface db 0 ;programming interface
.subclass db 0 ;sub-class
.class db 0 ;class code
.cache db 0 ;cache line size
.timer db 0 ;latency timer
.typed db 0 ;header type
;bits 6-0: header format
;00h other
;01h PCI-to-PCI bridge
;02h PCI-to-CardBus bridge
;bit 7: multi-function device
result db 0 ;Built-In Self-Test result
ends pcidata
.result db 0 ;Built-In Self-Test result
}
struc pciinf
version_major db 0
version_minor db 0
types db 0
maxbus db 0
ends pciinf
{
.version_major db 0
.version_minor db 0
.types db 0
.maxbus db 0
}
multifunction equ 80h
othercard equ 00h

View File

@ -1,4 +1,4 @@
;Adresses de port du contrleur IRQ
;Adresses de port du controleur IRQ
MASTERPIC = 020h ;Adresse de base du PIC maŒtre
SLAVEPIC = 0A0h ;Adresse de base du PIC esclave
IRQMASK = 001h ;Offset sur port de masquage
@ -14,7 +14,7 @@
;Position des vecteurs d'interruptions
MASTERFIRSTVECTOR = 008h ;Vecteurs logiciels des interruptions
SLAVEFIRSTVECTOR = 070h ;lectroniques
SLAVEFIRSTVECTOR = 070h ;electroniques
;OCW3 codes registres
IRR = 002h ;Interrupt Request Register
@ -24,20 +24,18 @@
POLLING = 004h ;Polling bit
ISR = 0Bh ; Pas d'opration, pas de Poll, lire ISR OCW3
IRR = 0Ah ; Pas d'opration, pas de Poll, lire IRR
ISR = 0Bh ; Pas d'operation, pas de Poll, lire ISR OCW3
IRR = 0Ah ; Pas d'operation, pas de Poll, lire IRR
;Autorise une interruption lectronique
;Entre : %1 - Numro de l'interruption (0-15) … autoriser 0-7 = MASTERPIC , 8-15 = SLAVEPIC
PROC enableirq FAR
ARG @irq:word
USES ax,cx,dx
mov ax,[@irq]
;Autorise une interruption electronique
;Entree : %1 - Numero de l'interruption (0-15) à autoriser 0-7 = MASTERPIC , 8-15 = SLAVEPIC
proc enableirq, irq
mov ax,[irq]
mov dx,MASTERPIC+IRQMASK
cmp al,7
jbe @@master
jbe .master
mov dx,SLAVEPIC+IRQMASK
@@master:
.master:
mov cl,al
and cl,7
mov al,1
@ -47,20 +45,18 @@ PROC enableirq FAR
in al,dx
and al,ah
out dx,al
ret
endp enableirq
retf
endp
;Desactive une interruption lectronique
;Entre : %0 - Numro de l'interruption (0-15) … desactiver 0-7 = MASTERPIC , 8-15 = SLAVEPIC
PROC disableirq FAR
ARG @irq:word
USES ax,cx,dx
mov ax,[@irq]
proc disableirq, irq
mov ax,[irq]
mov dx,MASTERPIC+IRQMASK
cmp al,7
jbe @@master
jbe .master
mov dx,SLAVEPIC+IRQMASK
@@master:
.master:
mov cl,al
and cl,7
mov al,1
@ -70,106 +66,94 @@ PROC disableirq FAR
in al,dx
or al,ah
out dx,al
ret
endp disableirq
retf
endp
;Signale "End Of Interrupt" de l'interruption %0
PROC seteoi FAR
ARG @irq:word
USES ax,dx
mov ax,[@irq]
proc seteoi, irq
mov ax,[irq]
cmp al,7
jbe @@master
jbe .master
mov al,EOI
out SLAVEPIC,al
@@master:
.master:
mov al,EOI
out MASTERPIC,al
ret
endp seteoi
retf
endp
;Lit les masques d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1
PROC readimr FAR
ARG @controleur:word
USES bx,dx
mov bx,[@controleur]
proc readimr, controleurx
mov bx,[controleur]
mov dx,MASTERPIC+ IRQMASK
cmp bl,0
jne @@master
jne .master
mov dx,SLAVEPIC+ IRQMASK
@@master:
.master:
xor ah,ah
in al,dx
pop dx
ret
endp readimr
retf
endp
;Lit le registre d'tat d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1
PROC readisr FAR
ARG @controleur:word
USES bx,dx
mov bx,[@controleur]
proc readisr, controleur
mov bx,[controleur]
mov dx,MASTERPIC
cmp bh,0
jne @@master
jne .master
mov dx,SLAVEPIC
@@master:
.master:
mov al,ISR
out dx,al
xor ah,ah
in al,dx
ret
endp readisr
retf
endp
;Lit le registre d'tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh
PROC readirr FAR
ARG @controleur:word
USES bx,dx
mov bx,[@controleur]
proc readirr, controleur
mov bx,[controleur]
mov dx,MASTERPIC
cmp bh,0
jne @@master
jne .master
mov dx,SLAVEPIC
@@master:
.master:
mov al,IRR
out dx,al
xor ah,ah
in al,dx
ret
endp readirr
retf
endp
;carry si enable et pas carry si pas enable
PROC isenableirq FAR
ARG @irq:word
USES ax,cx,dx
mov ax,[@irq]
proc isenableirq, irq
mov ax,[irq]
mov dx,MASTERPIC+IRQMASK
cmp al,7
jbe @@master
jbe .master
mov dx,SLAVEPIC+IRQMASK
@@master:
.master:
mov cl,al
and cx,7
in al,dx
neg al
bt ax,cx
ret
endp isenableirq
retf
endp
;carry si enable et pas carry si pas enable
PROC isinserviceirq FAR
ARG @irq:word
USES ax,cx,dx
mov ax,[@irq]
proc isinserviceirq, irq
mov ax,[irq]
mov dx,MASTERPIC
cmp al,7
jbe @@master
jbe .master
mov dx,SLAVEPIC
@@master:
.master:
mov cl,al
mov al,ISR
out dx,al
@ -177,20 +161,18 @@ PROC isinserviceirq FAR
in al,dx
neg al
bt ax,cx
ret
endp isinserviceirq
retf
endp
;carry si enable et pas carry si pas enable
PROC isrequestirq FAR
ARG @irq:word
USES ax,cx,dx
mov ax,[@irq]
proc isrequestirq, irq
mov ax,[irq]
mov dx,MASTERPIC
cmp al,7
jbe @@master
jbe .master
mov dx,SLAVEPIC
@@master:
.master:
mov cl,al
mov al,IRR
out dx,al
@ -198,83 +180,80 @@ PROC isrequestirq FAR
in al,dx
neg al
bt ax,cx
ret
endp isrequestirq
retf
endp
PROC installirqhandler FAR
USES eax,bx,cx,edx,si,di,ds,es
proc installirqhandler
push fs
call mbcreate,offset interruptionbloc,256*size ints
stdcall mbcreate,interruptionbloc,256*ints.sizeof
mov es,ax
mov ax,0x0000
mov ds,ax
xor si,si
@@searchdummypointer:
mov fs,[(vector si).data.seg]
mov bx,[(vector si).data.off]
cmp [byte ptr fs:bx],0xCF ;iret
je @@founded
add si,size vector
.searchdummypointer:
mov fs,[si+vector.data.seg]
mov bx,[si+vector.data.off]
cmp byte [fs:bx],0xCF ;iret
je .founded
add si,vector.sizeof
cmp si,256*4
jb @@searchdummypointer
jb .searchdummypointer
xor edx,edx
jmp @@suite
@@founded:
mov edx,[(vector si).content]
@@suite:
jmp .suite
.founded:
mov edx,[si+vector.content]
.suite:
xor cx,cx
xor si,si
xor di,di
cli
@@copy:
mov [es:(ints di).number],cl
mov [es:(ints di).locked],0
mov [es:(ints di).vector1.content],0
mov [es:(ints di).vector3.content],0
mov [es:(ints di).vector4.content],0
mov [es:(ints di).vector5.content],0
mov [es:(ints di).vector6.content],0
mov [es:(ints di).vector7.content],0
mov [es:(ints di).vector8.content],0
mov [es:(ints di).launchedlow],0
mov [es:(ints di).launchedhigh],0
mov [es:(ints di).calledlow],0
mov [es:(ints di).calledhigh],0
mov eax,[(vector si).content]
.copy:
mov [es:di+ints.number],cl
mov [es:di+ints.locked],0
mov [es:di+ints.vector1.content],0
mov [es:di+ints.vector3.content],0
mov [es:di+ints.vector4.content],0
mov [es:di+ints.vector5.content],0
mov [es:di+ints.vector6.content],0
mov [es:di+ints.vector7.content],0
mov [es:di+ints.vector8.content],0
mov [es:di+ints.launchedlow],0
mov [es:di+ints.launchedhigh],0
mov [es:di+ints.calledlow],0
mov [es:di+ints.calledhigh],0
mov eax,[si+vector.ints.content]
cmp eax,edx
je @@notarealvector
mov [es:(ints di).vector1.content],eax
mov [es:(ints di).activated],1
jmp @@copynext
@@notarealvector:
mov [es:(ints di).vector1.content],0
mov [es:(ints di).activated],0
@@copynext:
je .notarealvector
mov [es:di+ints.vector1.content],eax
mov [es:di+ints.activated],1
jmp .copynext
.notarealvector:
mov [es:di+ints.vector1.content],0
mov [es:di+ints.activated],0
.copynext:
mov bx,cx
shl bx,3
sub bx,cx
add bx,offset coupling
mov [(vector si).data.seg],cs
mov [(vector si).data.off],bx
add si,size vector
add di,size ints
add bx,coupling
mov [si+vector.data.seg],cs
mov [si+vector.data.off],bx
add si,vector.sizeof
add di,ints.sizeof
inc cl
cmp cl,0
jne @@copy
@@end:
jne .copy
.end:
pop fs
sti
ret
endp installirqhandler
retf
endp
interruptionbloc db '/interrupts',0
PROC savecontext FAR
ARG @pointer:word
USES eax,si,ds
proc savecontext, pointer
pushfd
push eax
push ebx
@ -287,125 +266,121 @@ push es
push fs
push gs
push ss
mov si,[@pointer]
mov si,[pointer]
mov ds,[ss:bp+4]
mov eax,ebp
mov ax,[word ptr ss:bp]
mov ax,word [ss:bp]
push eax
push [word ptr ss:bp+4]
push word [ss:bp+4]
xor eax,eax
mov ax,[word ptr ss:bp+2]
mov ax,word [ss:bp+2]
push eax
mov ax,bp
add ax,4
push eax
pop [(regs si).sesp]
pop [(regs si).seip]
pop [(regs si).scs]
pop [(regs si).sebp]
pop [(regs si).sss]
pop [(regs si).sgs]
pop [(regs si).sfs]
pop [(regs si).ses]
pop [(regs si).sds]
pop [(regs si).sedi]
pop [(regs si).sesi]
pop [(regs si).sedx]
pop [(regs si).secx]
pop [(regs si).sebx]
pop [(regs si).seax]
pop [(regs si).seflags]
ret
endp savecontext
pop [si+regs.sesp]
pop [si+regs.seip]
pop [si+regs.scs]
pop [si+regs.sebp]
pop [si+regs.sss]
pop [si+regs.sgs]
pop [si+regs.sfs]
pop [si+regs.ses]
pop [si+regs.sds]
pop [si+regs.sedi]
pop [si+regs.sesi]
pop [si+regs.sedx]
pop [si+regs.secx]
pop [si+regs.sebx]
pop [si+regs.seax]
pop [si+regs.seflags]
retf
endp
PROC restorecontextg FAR
ARG @pointer:word
mov si,[@pointer]
pushd [cs:(regs si).sesi]
pushd [cs:(regs si).seflags]
mov eax,[cs:(regs si).seax]
mov ebx,[cs:(regs si).sebx]
mov ecx,[cs:(regs si).secx]
mov edx,[cs:(regs si).sedx]
mov edi,[cs:(regs si).sedi]
mov ebp,[cs:(regs si).sebp]
mov es,[cs:(regs si).ses]
mov fs,[cs:(regs si).sfs]
mov gs,[cs:(regs si).sgs]
mov ds,[cs:(regs si).sds]
proc restorecontextg, pointer
mov si,[pointer]
pushd [cs:si+regs.sesi]
pushd [cs:si+regs.seflags]
mov eax,[cs:si+regs.seax]
mov ebx,[cs:si+regs.sebx]
mov ecx,[cs:si+regs.secx]
mov edx,[cs:si+regs.sedx]
mov edi,[cs:si+regs.sedi]
mov ebp,[cs:si+regs.sebp]
mov es,[cs:si+regs.ses]
mov fs,[cs:si+regs.sfs]
mov gs,[cs:si+regs.sgs]
mov ds,[cs:si+regs.sds]
popfd
pop esi
pop [cs:dummy]
db 0xCA,0x02,0x00 ;retf 2
endp restorecontextg
endp
coupling:
counter = 0
REPEAT 256
push counter+256
repeat 256
push %+256
push offset irqhandlers
ret
counter = counter + 1
ENDM
end repeat
interrupt dw 0
dummy dw 0
calling_reg regs <>
function_reg regs <>
calling_reg regs
function_reg regs
irqhandlers:
cli
pop [cs:interrupt]
call savecontext,offset calling_reg
call irqhandler,[cs:interrupt]
call restorecontextg,offset calling_reg
stdcall savecontext,offset calling_reg
stdcall irqhandler,[cs:interrupt]
stdcall restorecontextg,offset calling_reg
sti
iret
PROC irqhandler NEAR
ARG @int:word
proc irqhandler, int
push cs
pop ds
call mbfindsb,offset interruptionbloc,cs
jc @@end
stdcall mbfindsb,offset interruptionbloc,cs
jc .end
mov es,ax
mov ax,[@int]
mov ax,[int]
sub ax,256
mov cx,size ints
mov cx,ints.sizeof
mul cx
mov si,ax
add [es:(ints si).calledlow],1
adc [es:(ints si).calledhigh],0
cmp [es:(ints si).activated],1
jne @@end
add [es:(ints si).launchedlow],1
adc [es:(ints si).launchedhigh],0
lea si,[es:(ints si).vector1]
add [es:si+ints.calledlow],1
adc [es:si+ints.calledhigh],0
cmp [es:si+ints.activated],1
jne .end
add [es:si+ints.launchedlow],1
adc [es:si+ints.launchedhigh],0
lea si,[es:si+ints.vector1]
mov cl,8
@@launchall:
cmp [es:(vector si).content],0
je @@end
push [word ptr cs:calling_reg.seflags]
.launchall:
cmp [es:si+vector.content],0
je .end
push word [cs:calling_reg.seflags]
push cs
push offset @@back
push [es:(vector si).data.seg]
push [es:(vector si).data.off]
call savecontext,offset function_reg
call restorecontextg,offset calling_reg
push offset .back
push [es:si+vector.data.seg]
push [es:si+vector.data.off]
stdcall savecontext,offset function_reg
stdcall restorecontextg,offset calling_reg
db 0xCB
@@back:
.back:
cli
call savecontext,offset calling_reg
call restorecontextg,offset function_reg
@@next:
add si,size vector
stdcall savecontext,offset calling_reg
stdcall restorecontextg,offset function_reg
.next:
add si,vector.sizeof
dec cl
jnz @@launchall
@@end:
jnz .launchall
.end:
ret
endp irqhandler
endp

View File

@ -1,83 +1,16 @@
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../include -m32 -fno-pie -no-pie -c -o
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie -I ../include -D__ASSEMBLY__ -c -o
LINK=ld -m elf_i386 -n
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGEPERM=chmod 644
NM=nm
OBJCOPY=objcopy -O binary -R .note -R .comment -S
OBJDEBUG=objcopy --only-keep-debug
ZOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
VOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'
COMP=gzip -9 -f
BUILD=../tools/build
MKPIGGY=../tools/mkpiggy
ASM=fasm
CLEAN=rm -rf
all: system.sys
all: systeme.sys disque.sys video.sys
system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin
$(BUILD) realmode/setup.bin system.bin zoffset.h system.sys
sync
systeme.sys: systeme.asm
$(ASM) $^
allpiggy.o: piggy.o decompress.o header.o
$(LINK) -T allpiggy piggy.o decompress.o header.o
disque.sys: disque.asm
$(ASM) $^
voffset.h: system
$(NM) system|$(VOFFSET)>voffset.h
zoffset.h: piggy.o
$(NM) piggy.o|$(ZOFFSET)>zoffset.h
togit: clean indent
piggy.o: piggy.S
$(ASM) $@ $^
system: system.o system_asm.o ../lib/libs.o
$(LINK) -T system.ld system.o system_asm.o ../lib/libs.o
$(OBJDEBUG) system system.sym
$(NM) system > system.map
system.bin: system
$(OBJCOPY) $^ $@
system.bin.gz: system.bin
cat $^|$(COMP) > $@
piggy.S: system.bin.gz
$(MKPIGGY) $^ > $@
realmode/setup.bin:
make -C realmode
system.o: system.c
$(GCC) $@ $^
system_asm.o: system_asm.S
$(ASM) $@ $^
video.sys: video.asm
$(ASM) $^
clean:
make -C realmode clean
$(REMOVE) system
$(REMOVE) piggy.S
$(REMOVE) *.o
$(REMOVE) *.tmp
$(REMOVE) *.sym
$(REMOVE) *.map
$(REMOVE) *.gz
$(REMOVE) *.h
$(REMOVE) *.out
$(REMOVE) *.bin
$(REMOVE) *.sys
$(REMOVE) *.s
$(REMOVE) *.c~
sync
indent:
make -C realmode indent
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
sync
$(CLEAN) *.sys

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,3 @@
model tiny,stdcall
p586N
locals
jumps
codeseg
option procalign:byte
include "..\include\mem.h"
include "..\include\divers.h"
@ -16,7 +10,7 @@ memorystart equ 0052h ;premier bloc de la m
org 0h
mb0:
header exe <"CE",1,0,0,offset exports,offset imports,offset section,offset start>
header exe 1
start:
push cs
@ -27,20 +21,20 @@ start:
pop es
pop fs
pop gs
call biosprint,offset return
call biosprint,offset msg_memory
call biosprint,offset return
call biosprint,offset msg_memory_init
call mbinit
stdcall biosprint,makereturn
stdcall biosprint,msg_memory
stdcall biosprint,makereturn
stdcall biosprint,msg_memory_init
stdcall mbinit
jc error
call biosprint,offset msg_ok
call biosprint,offset msg_memory_section
stdcall biosprint,msg_ok
stdcall biosprint,msg_memory_section
mov ax,cs
call mbloadsection,ax
stdcall mbloadsection,ax
jc error
call biosprint,offset msg_ok
call biosprint,offset msg_memory_jumps
jmp [dword ptr cs:pointer]
stdcall biosprint,msg_ok
stdcall biosprint,msg_memory_jumps
jmp dword [cs:pointer]
pointer:
dw suite
dw memorystart
@ -53,29 +47,29 @@ suite:
pop es
pop fs
pop gs
call biosprint,offset msg_ok
call biosprint,offset msg_video_init
call [cs:setvideomode],2
stdcall biosprint,msg_ok
stdcall biosprint,msg_video_init
stdcall [cs:setvideomode],2
jc error
call [cs:clearscreen]
call [cs:print],offset msg_memory
call [cs:print],offset msg_ok2
call [cs:print],offset msg_memory_init
call [cs:print],offset msg_ok2
call [cs:print],offset msg_memory_section
call [cs:print],offset msg_ok2
call [cs:print],offset msg_memory_jumps
call [cs:print],offset msg_ok2
call [cs:print],offset msg_video_init
call [cs:print],offset msg_ok2
call [cs:print],offset msg_handler
;call installirqhandler
call [cs:print],offset msg_ok2
call [cs:print],offset msg_cpu_detect
call [cs:cpuinfo],offset thecpu
call [cs:setinfo],offset thecpu,offset temp
call [cs:print],offset msg_ok2
push offset temp
stdcall [cs:clearscreen]
stdcall [cs:print],msg_memory
stdcall [cs:print],msg_ok2
stdcall [cs:print],msg_memory_init
stdcall [cs:print],msg_ok2
stdcall [cs:print],msg_memory_section
stdcall [cs:print],msg_ok2
stdcall [cs:print],msg_memory_jumps
stdcall [cs:print],msg_ok2
stdcall [cs:print],msg_video_init
stdcall [cs:print],msg_ok2
stdcall [cs:print],msg_handler
;stdcall installirqhandler
stdcall [cs:print],msg_ok2
stdcall [cs:print],msg_cpu_detect
stdcall [cs:cpuinfo],thecpu
stdcall [cs:setinfo],thecpu,temporary
stdcall [cs:print],msg_ok2
push temporary
xor eax,eax
mov al,[thecpu.family]
push eax
@ -83,13 +77,13 @@ suite:
push eax
mov al,[thecpu.stepping]
push eax
push offset thecpu.names
push offset thecpu.vendor
call [cs:print],offset msg_cpu_detect_inf
call [cs:print],offset msg_pci
call [cs:pciinfo],offset thepci
push thecpu.names
push thecpu.vendor
stdcall [cs:print],msg_cpu_detect_inf
stdcall [cs:print],msg_pci
stdcall [cs:pciinfo],thepci
jc nopci
call [cs:print],offset msg_ok2
stdcall [cs:print],msg_ok2
xor eax,eax
mov al,[thepci.maxbus]
push eax
@ -97,25 +91,25 @@ suite:
push eax
mov al,[thepci.version_major]
push eax
call [cs:print],offset msg_pci_info
call [cs:print],offset msg_pci_enum
stdcall [cs:print],msg_pci_info
stdcall [cs:print],msg_pci_enum
xor ebx,ebx
xor ecx,ecx
xor si,si
searchpci:
call [cs:getcardinfo],bx,cx,si,offset temp
stdcall [cs:getcardinfo],bx,cx,si,temporary
jc stopthis
mov al,[(pcidata offset temp).subclass]
mov al,[temporary+pcidata.subclass]
push ax
mov al,[(pcidata offset temp).class]
mov al,[temporary+pcidata.class]
push ax
call [cs:getpcisubclass]
stdcall [cs:getpcisubclass]
push dx
push ax
mov al,[(pcidata offset temp).class]
mov al,[temporary+pcidata.class]
xor ah,ah
push ax
call [cs:getpciclass]
stdcall [cs:getpciclass]
push dx
push ax
push 4
@ -124,11 +118,11 @@ searchpci:
push ecx
push 4
push ebx
mov ax,[(pcidata offset temp).device]
mov ax,[temporary+pcidata.device]
push eax
mov ax,[(pcidata offset temp).vendor]
mov ax,[temporary+pcidata.vendor]
push eax
call [cs:print],offset msg_pci_card
stdcall [cs:print],msg_pci_card
inc si
cmp si,7
jbe searchpci
@ -143,42 +137,42 @@ stopthis:
jbe searchpci
jmp next
nopci:
call [cs:print],offset msg_echec2
stdcall [cs:print],msg_echec2
next:
;call [cs:detectvmware]
;stdcall [cs:detectvmware]
;jne novirtual
;call [cs:print],offset msg_vmware
;stdcall [cs:print],msg_vmware
novirtual:
;call [cs:print],offset msg_flat
;call enablea20
;call flatmode
;stdcall [cs:print],msg_flat
;stdcall enablea20
;stdcall flatmode
;xor ax,ax
;mov fs,ax
;mov esi,0100000h
;mov [dword ptr fs:esi],"OKIN"
call [cs:print],offset msg_ok2
call [cs:print],offset msg_disk_init
call [cs:initdrive]
stdcall [cs:print],msg_ok2
stdcall [cs:print],msg_disk_init
stdcall [cs:initdrive]
jc error2
call [cs:print],offset msg_ok2
call [cs:print],offset msg_launchcommand
call [cs:execfile],offset shell
stdcall [cs:print],msg_ok2
stdcall [cs:print],msg_launchcommand
stdcall [cs:execfile],shell
jc error2
error2:
call [cs:print],offset msg_error2
call bioswaitkey
stdcall [cs:print],msg_error2
stdcall bioswaitkey
jmp far 0FFFFh:0000h
error:
call biosprint,offset msg_error
call bioswaitkey
stdcall biosprint,msg_error
stdcall bioswaitkey
jmp far 0FFFFh:0000h
shell find <"COMMANDE.CE",0,0,0,1,>
thepci pciinf <>
thecpu cpu <>
temp db 256 dup (0)
return db 0dh,0ah,0
shell find "COMMANDE.CE\0"
thepci pciinf
thecpu cpu
temporary db 256 dup (0)
makereturn db 0dh,0ah,0
msg_memory db "Initialisation de la memoire",0
msg_memory_init db " -Creation du bloc primordial",0
msg_memory_section db " -Developpement des sections",0
@ -260,37 +254,37 @@ endi
include "mcb.asm"
include "8259a.asm"
section:
dw offset mb0
dw offset mb1-offset mb0
allsection:
dw mb0
dw mb1-mb0
db "SYSTEME",0
dw offset mb1
dw offset mb2-offset mb1
dw mb1
dw mb2-mb1
db "VIDEO",0
dw offset mb2
dw offset mb3-offset mb2
dw mb2
dw mb3-mb2
db "VIDEO.LIB",0
dw offset mb3
dw offset mb4-offset mb3
dw mb3
dw mb4-mb3
db "DETECT.LIB",0
dw offset mb4
dw offset mb5-offset mb4
dw mb4
dw mb5-mb4
db "DISQUE",0
dd 0
mb1:
includebin "video.sys"
file "video.sys"
mb2:
includebin "..\lib\video.lib"
file "..\lib\video.lib"
mb3:
includebin "..\lib\detect.lib"
file "..\lib\detect.lib"
mb4:
includebin "disque.sys"
file "disque.sys"
mb5: