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 struc cpu
vendor db 13 dup(0) ;Chaine 0 du fabriquant {
names db 32 dup(0) .vendor db 13 dup(0) ;Chaine 0 du fabriquant
stepping db 0 .names db 32 dup(0)
models db 0 .stepping db 0
family db 0 .models db 0
types db 0 .family db 0
emodels db 0 .types db 0
efamily db 0 .emodels db 0
mmx db 0 .efamily db 0
mmx2 db 0 .mmx db 0
sse db 0 .mmx2 db 0
sse2 db 0 .sse db 0
sse3 db 0 .sse2 db 0
fpu db 0 .sse3 db 0
now3d db 0 .fpu db 0
now3d2 db 0 .now3d db 0
htt db 0 .now3d2 db 0
apic db 0 .htt db 0
ends cpu .apic db 0
}

View File

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

View File

@ -26,17 +26,19 @@ struc regs
;.sst7 dt 0 ;.sst7 dt 0
} }
struc tuple struc tuple off,seg
{ {
.off dw 0 ;adresse .off dw 0 ;adresse
.seg dw 0 ;segment .seg dw 0 ;segment
} }
;union vector struc vector off,seg
;{ {
;.data tuple 0,0 .data tuple off,seg
;.content dd 0 virtual at .data
;} .content dd 0
end virtual
}
struc ints ;bloc interruption struc ints ;bloc interruption
{ {
@ -55,9 +57,11 @@ struc ints ;bloc interruption
.vector6 vector ? .vector6 vector ?
.vector7 vector ? .vector7 vector ?
.vector8 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. .check db "NH" ;signature du bloc de mémoire.
.isnotlast db 0 ;flag indiquant le dernier bloc .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 .reference dw 0 ;pointeur vers le bloc parent
.sizes dw 0 ;taille du bloc en paragraphe de 16 octet .sizes dw 0 ;taille du bloc en paragraphe de 16 octet
.names db 24 dup (0) ;nom du bloc .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 .checks db "CE" ;signature de l'exe
.major db 1 ;N° version .major db 1 ;N° version
@ -79,7 +85,7 @@ struc exe ;Executable COS
.starting dw 15 .starting dw 15
} }
struc descriptor struc descriptor limit_low,base_low,base_middle,dpltype,limit_high,base_high
{ {
.limit_low dw 0 .limit_low dw 0
.base_low dw 0 .base_low dw 0
@ -87,6 +93,7 @@ struc descriptor
.dpltype db 0 .dpltype db 0
.limit_high db 0 .limit_high db 0
.base_high db 0 .base_high db 0
.sizeof = $ - .limit_low
} }
free equ 0 ;Reference quand libre free equ 0 ;Reference quand libre
@ -137,7 +144,273 @@ macro declare fonction*
dw fonction dw fonction
} }
macro heading versmaj*,versmin*,start*
{ ; Macroinstructions for defining and calling procedures
header exe "CE",versmaj,versmin,0,exports,imports,0,start
} 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 struc pcidata
vendor dw 0 ;vendor ID (read-only), FFFFh returned if requested device non-existent {
device dw 0 ;device ID (read-only) .vendor dw 0 ;vendor ID (read-only), FFFFh returned if requested device non-existent
command dw 0 ;command register .device dw 0 ;device ID (read-only)
status dw 0 ;status register .command dw 0 ;command register
revision db 0 ;revision ID .status dw 0 ;status register
interface db 0 ;programming interface .revision db 0 ;revision ID
subclass db 0 ;sub-class .interface db 0 ;programming interface
class db 0 ;class code .subclass db 0 ;sub-class
cache db 0 ;cache line size .class db 0 ;class code
timer db 0 ;latency timer .cache db 0 ;cache line size
typed db 0 ;header type .timer db 0 ;latency timer
.typed db 0 ;header type
;bits 6-0: header format ;bits 6-0: header format
;00h other ;00h other
;01h PCI-to-PCI bridge ;01h PCI-to-PCI bridge
;02h PCI-to-CardBus bridge ;02h PCI-to-CardBus bridge
;bit 7: multi-function device ;bit 7: multi-function device
result db 0 ;Built-In Self-Test result .result db 0 ;Built-In Self-Test result
ends pcidata }
struc pciinf struc pciinf
version_major db 0 {
version_minor db 0 .version_major db 0
types db 0 .version_minor db 0
maxbus db 0 .types db 0
ends pciinf .maxbus db 0
}
multifunction equ 80h multifunction equ 80h
othercard equ 00h 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 MASTERPIC = 020h ;Adresse de base du PIC maŒtre
SLAVEPIC = 0A0h ;Adresse de base du PIC esclave SLAVEPIC = 0A0h ;Adresse de base du PIC esclave
IRQMASK = 001h ;Offset sur port de masquage IRQMASK = 001h ;Offset sur port de masquage
@ -14,7 +14,7 @@
;Position des vecteurs d'interruptions ;Position des vecteurs d'interruptions
MASTERFIRSTVECTOR = 008h ;Vecteurs logiciels des interruptions MASTERFIRSTVECTOR = 008h ;Vecteurs logiciels des interruptions
SLAVEFIRSTVECTOR = 070h ;lectroniques SLAVEFIRSTVECTOR = 070h ;electroniques
;OCW3 codes registres ;OCW3 codes registres
IRR = 002h ;Interrupt Request Register IRR = 002h ;Interrupt Request Register
@ -24,20 +24,18 @@
POLLING = 004h ;Polling bit POLLING = 004h ;Polling bit
ISR = 0Bh ; Pas d'opration, pas de Poll, lire ISR OCW3 ISR = 0Bh ; Pas d'operation, pas de Poll, lire ISR OCW3
IRR = 0Ah ; Pas d'opration, pas de Poll, lire IRR IRR = 0Ah ; Pas d'operation, pas de Poll, lire IRR
;Autorise une interruption lectronique ;Autorise une interruption electronique
;Entre : %1 - Numro de l'interruption (0-15) … autoriser 0-7 = MASTERPIC , 8-15 = SLAVEPIC ;Entree : %1 - Numero de l'interruption (0-15) à autoriser 0-7 = MASTERPIC , 8-15 = SLAVEPIC
PROC enableirq FAR proc enableirq, irq
ARG @irq:word mov ax,[irq]
USES ax,cx,dx
mov ax,[@irq]
mov dx,MASTERPIC+IRQMASK mov dx,MASTERPIC+IRQMASK
cmp al,7 cmp al,7
jbe @@master jbe .master
mov dx,SLAVEPIC+IRQMASK mov dx,SLAVEPIC+IRQMASK
@@master: .master:
mov cl,al mov cl,al
and cl,7 and cl,7
mov al,1 mov al,1
@ -47,20 +45,18 @@ PROC enableirq FAR
in al,dx in al,dx
and al,ah and al,ah
out dx,al out dx,al
ret retf
endp enableirq endp
;Desactive une interruption lectronique ;Desactive une interruption lectronique
;Entre : %0 - Numro de l'interruption (0-15) … desactiver 0-7 = MASTERPIC , 8-15 = SLAVEPIC ;Entre : %0 - Numro de l'interruption (0-15) … desactiver 0-7 = MASTERPIC , 8-15 = SLAVEPIC
PROC disableirq FAR proc disableirq, irq
ARG @irq:word mov ax,[irq]
USES ax,cx,dx
mov ax,[@irq]
mov dx,MASTERPIC+IRQMASK mov dx,MASTERPIC+IRQMASK
cmp al,7 cmp al,7
jbe @@master jbe .master
mov dx,SLAVEPIC+IRQMASK mov dx,SLAVEPIC+IRQMASK
@@master: .master:
mov cl,al mov cl,al
and cl,7 and cl,7
mov al,1 mov al,1
@ -70,106 +66,94 @@ PROC disableirq FAR
in al,dx in al,dx
or al,ah or al,ah
out dx,al out dx,al
ret retf
endp disableirq endp
;Signale "End Of Interrupt" de l'interruption %0 ;Signale "End Of Interrupt" de l'interruption %0
PROC seteoi FAR proc seteoi, irq
ARG @irq:word mov ax,[irq]
USES ax,dx
mov ax,[@irq]
cmp al,7 cmp al,7
jbe @@master jbe .master
mov al,EOI mov al,EOI
out SLAVEPIC,al out SLAVEPIC,al
@@master: .master:
mov al,EOI mov al,EOI
out MASTERPIC,al out MASTERPIC,al
ret retf
endp seteoi endp
;Lit les masques d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1 ;Lit les masques d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1
PROC readimr FAR proc readimr, controleurx
ARG @controleur:word mov bx,[controleur]
USES bx,dx
mov bx,[@controleur]
mov dx,MASTERPIC+ IRQMASK mov dx,MASTERPIC+ IRQMASK
cmp bl,0 cmp bl,0
jne @@master jne .master
mov dx,SLAVEPIC+ IRQMASK mov dx,SLAVEPIC+ IRQMASK
@@master: .master:
xor ah,ah xor ah,ah
in al,dx in al,dx
pop dx pop dx
ret retf
endp readimr endp
;Lit le registre d'tat d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1 ;Lit le registre d'tat d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1
PROC readisr FAR proc readisr, controleur
ARG @controleur:word mov bx,[controleur]
USES bx,dx
mov bx,[@controleur]
mov dx,MASTERPIC mov dx,MASTERPIC
cmp bh,0 cmp bh,0
jne @@master jne .master
mov dx,SLAVEPIC mov dx,SLAVEPIC
@@master: .master:
mov al,ISR mov al,ISR
out dx,al out dx,al
xor ah,ah xor ah,ah
in al,dx in al,dx
ret retf
endp readisr endp
;Lit le registre d'tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh ;Lit le registre d'tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh
PROC readirr FAR proc readirr, controleur
ARG @controleur:word mov bx,[controleur]
USES bx,dx
mov bx,[@controleur]
mov dx,MASTERPIC mov dx,MASTERPIC
cmp bh,0 cmp bh,0
jne @@master jne .master
mov dx,SLAVEPIC mov dx,SLAVEPIC
@@master: .master:
mov al,IRR mov al,IRR
out dx,al out dx,al
xor ah,ah xor ah,ah
in al,dx in al,dx
ret retf
endp readirr endp
;carry si enable et pas carry si pas enable ;carry si enable et pas carry si pas enable
PROC isenableirq FAR proc isenableirq, irq
ARG @irq:word mov ax,[irq]
USES ax,cx,dx
mov ax,[@irq]
mov dx,MASTERPIC+IRQMASK mov dx,MASTERPIC+IRQMASK
cmp al,7 cmp al,7
jbe @@master jbe .master
mov dx,SLAVEPIC+IRQMASK mov dx,SLAVEPIC+IRQMASK
@@master: .master:
mov cl,al mov cl,al
and cx,7 and cx,7
in al,dx in al,dx
neg al neg al
bt ax,cx bt ax,cx
ret retf
endp isenableirq endp
;carry si enable et pas carry si pas enable ;carry si enable et pas carry si pas enable
PROC isinserviceirq FAR proc isinserviceirq, irq
ARG @irq:word mov ax,[irq]
USES ax,cx,dx
mov ax,[@irq]
mov dx,MASTERPIC mov dx,MASTERPIC
cmp al,7 cmp al,7
jbe @@master jbe .master
mov dx,SLAVEPIC mov dx,SLAVEPIC
@@master: .master:
mov cl,al mov cl,al
mov al,ISR mov al,ISR
out dx,al out dx,al
@ -177,20 +161,18 @@ PROC isinserviceirq FAR
in al,dx in al,dx
neg al neg al
bt ax,cx bt ax,cx
ret retf
endp isinserviceirq endp
;carry si enable et pas carry si pas enable ;carry si enable et pas carry si pas enable
PROC isrequestirq FAR proc isrequestirq, irq
ARG @irq:word mov ax,[irq]
USES ax,cx,dx
mov ax,[@irq]
mov dx,MASTERPIC mov dx,MASTERPIC
cmp al,7 cmp al,7
jbe @@master jbe .master
mov dx,SLAVEPIC mov dx,SLAVEPIC
@@master: .master:
mov cl,al mov cl,al
mov al,IRR mov al,IRR
out dx,al out dx,al
@ -198,83 +180,80 @@ PROC isrequestirq FAR
in al,dx in al,dx
neg al neg al
bt ax,cx bt ax,cx
ret retf
endp isrequestirq endp
PROC installirqhandler FAR proc installirqhandler
USES eax,bx,cx,edx,si,di,ds,es
push fs push fs
call mbcreate,offset interruptionbloc,256*size ints stdcall mbcreate,interruptionbloc,256*ints.sizeof
mov es,ax mov es,ax
mov ax,0x0000 mov ax,0x0000
mov ds,ax mov ds,ax
xor si,si xor si,si
@@searchdummypointer: .searchdummypointer:
mov fs,[(vector si).data.seg] mov fs,[si+vector.data.seg]
mov bx,[(vector si).data.off] mov bx,[si+vector.data.off]
cmp [byte ptr fs:bx],0xCF ;iret cmp byte [fs:bx],0xCF ;iret
je @@founded je .founded
add si,size vector add si,vector.sizeof
cmp si,256*4 cmp si,256*4
jb @@searchdummypointer jb .searchdummypointer
xor edx,edx xor edx,edx
jmp @@suite jmp .suite
@@founded: .founded:
mov edx,[(vector si).content] mov edx,[si+vector.content]
@@suite: .suite:
xor cx,cx xor cx,cx
xor si,si xor si,si
xor di,di xor di,di
cli cli
@@copy: .copy:
mov [es:(ints di).number],cl mov [es:di+ints.number],cl
mov [es:(ints di).locked],0 mov [es:di+ints.locked],0
mov [es:(ints di).vector1.content],0 mov [es:di+ints.vector1.content],0
mov [es:(ints di).vector3.content],0 mov [es:di+ints.vector3.content],0
mov [es:(ints di).vector4.content],0 mov [es:di+ints.vector4.content],0
mov [es:(ints di).vector5.content],0 mov [es:di+ints.vector5.content],0
mov [es:(ints di).vector6.content],0 mov [es:di+ints.vector6.content],0
mov [es:(ints di).vector7.content],0 mov [es:di+ints.vector7.content],0
mov [es:(ints di).vector8.content],0 mov [es:di+ints.vector8.content],0
mov [es:(ints di).launchedlow],0 mov [es:di+ints.launchedlow],0
mov [es:(ints di).launchedhigh],0 mov [es:di+ints.launchedhigh],0
mov [es:(ints di).calledlow],0 mov [es:di+ints.calledlow],0
mov [es:(ints di).calledhigh],0 mov [es:di+ints.calledhigh],0
mov eax,[(vector si).content] mov eax,[si+vector.ints.content]
cmp eax,edx cmp eax,edx
je @@notarealvector je .notarealvector
mov [es:(ints di).vector1.content],eax mov [es:di+ints.vector1.content],eax
mov [es:(ints di).activated],1 mov [es:di+ints.activated],1
jmp @@copynext jmp .copynext
@@notarealvector: .notarealvector:
mov [es:(ints di).vector1.content],0 mov [es:di+ints.vector1.content],0
mov [es:(ints di).activated],0 mov [es:di+ints.activated],0
@@copynext: .copynext:
mov bx,cx mov bx,cx
shl bx,3 shl bx,3
sub bx,cx sub bx,cx
add bx,offset coupling add bx,coupling
mov [(vector si).data.seg],cs mov [si+vector.data.seg],cs
mov [(vector si).data.off],bx mov [si+vector.data.off],bx
add si,size vector add si,vector.sizeof
add di,size ints add di,ints.sizeof
inc cl inc cl
cmp cl,0 cmp cl,0
jne @@copy jne .copy
@@end: .end:
pop fs pop fs
sti sti
ret retf
endp installirqhandler endp
interruptionbloc db '/interrupts',0 interruptionbloc db '/interrupts',0
PROC savecontext FAR proc savecontext, pointer
ARG @pointer:word
USES eax,si,ds
pushfd pushfd
push eax push eax
push ebx push ebx
@ -287,125 +266,121 @@ push es
push fs push fs
push gs push gs
push ss push ss
mov si,[@pointer] mov si,[pointer]
mov ds,[ss:bp+4] mov ds,[ss:bp+4]
mov eax,ebp mov eax,ebp
mov ax,[word ptr ss:bp] mov ax,word [ss:bp]
push eax push eax
push [word ptr ss:bp+4] push word [ss:bp+4]
xor eax,eax xor eax,eax
mov ax,[word ptr ss:bp+2] mov ax,word [ss:bp+2]
push eax push eax
mov ax,bp mov ax,bp
add ax,4 add ax,4
push eax push eax
pop [(regs si).sesp] pop [si+regs.sesp]
pop [(regs si).seip] pop [si+regs.seip]
pop [(regs si).scs] pop [si+regs.scs]
pop [(regs si).sebp] pop [si+regs.sebp]
pop [(regs si).sss] pop [si+regs.sss]
pop [(regs si).sgs] pop [si+regs.sgs]
pop [(regs si).sfs] pop [si+regs.sfs]
pop [(regs si).ses] pop [si+regs.ses]
pop [(regs si).sds] pop [si+regs.sds]
pop [(regs si).sedi] pop [si+regs.sedi]
pop [(regs si).sesi] pop [si+regs.sesi]
pop [(regs si).sedx] pop [si+regs.sedx]
pop [(regs si).secx] pop [si+regs.secx]
pop [(regs si).sebx] pop [si+regs.sebx]
pop [(regs si).seax] pop [si+regs.seax]
pop [(regs si).seflags] pop [si+regs.seflags]
ret retf
endp savecontext endp
PROC restorecontextg FAR proc restorecontextg, pointer
ARG @pointer:word mov si,[pointer]
mov si,[@pointer] pushd [cs:si+regs.sesi]
pushd [cs:(regs si).sesi] pushd [cs:si+regs.seflags]
pushd [cs:(regs si).seflags] mov eax,[cs:si+regs.seax]
mov eax,[cs:(regs si).seax] mov ebx,[cs:si+regs.sebx]
mov ebx,[cs:(regs si).sebx] mov ecx,[cs:si+regs.secx]
mov ecx,[cs:(regs si).secx] mov edx,[cs:si+regs.sedx]
mov edx,[cs:(regs si).sedx] mov edi,[cs:si+regs.sedi]
mov edi,[cs:(regs si).sedi] mov ebp,[cs:si+regs.sebp]
mov ebp,[cs:(regs si).sebp] mov es,[cs:si+regs.ses]
mov es,[cs:(regs si).ses] mov fs,[cs:si+regs.sfs]
mov fs,[cs:(regs si).sfs] mov gs,[cs:si+regs.sgs]
mov gs,[cs:(regs si).sgs] mov ds,[cs:si+regs.sds]
mov ds,[cs:(regs si).sds]
popfd popfd
pop esi pop esi
pop [cs:dummy] pop [cs:dummy]
db 0xCA,0x02,0x00 ;retf 2 db 0xCA,0x02,0x00 ;retf 2
endp restorecontextg endp
coupling: coupling:
counter = 0 repeat 256
REPEAT 256 push %+256
push counter+256
push offset irqhandlers push offset irqhandlers
ret ret
counter = counter + 1 end repeat
ENDM
interrupt dw 0 interrupt dw 0
dummy dw 0 dummy dw 0
calling_reg regs <> calling_reg regs
function_reg regs <> function_reg regs
irqhandlers: irqhandlers:
cli cli
pop [cs:interrupt] pop [cs:interrupt]
call savecontext,offset calling_reg stdcall savecontext,offset calling_reg
call irqhandler,[cs:interrupt] stdcall irqhandler,[cs:interrupt]
call restorecontextg,offset calling_reg stdcall restorecontextg,offset calling_reg
sti sti
iret iret
PROC irqhandler NEAR proc irqhandler, int
ARG @int:word
push cs push cs
pop ds pop ds
call mbfindsb,offset interruptionbloc,cs stdcall mbfindsb,offset interruptionbloc,cs
jc @@end jc .end
mov es,ax mov es,ax
mov ax,[@int] mov ax,[int]
sub ax,256 sub ax,256
mov cx,size ints mov cx,ints.sizeof
mul cx mul cx
mov si,ax mov si,ax
add [es:(ints si).calledlow],1 add [es:si+ints.calledlow],1
adc [es:(ints si).calledhigh],0 adc [es:si+ints.calledhigh],0
cmp [es:(ints si).activated],1 cmp [es:si+ints.activated],1
jne @@end jne .end
add [es:(ints si).launchedlow],1 add [es:si+ints.launchedlow],1
adc [es:(ints si).launchedhigh],0 adc [es:si+ints.launchedhigh],0
lea si,[es:(ints si).vector1] lea si,[es:si+ints.vector1]
mov cl,8 mov cl,8
@@launchall: .launchall:
cmp [es:(vector si).content],0 cmp [es:si+vector.content],0
je @@end je .end
push [word ptr cs:calling_reg.seflags] push word [cs:calling_reg.seflags]
push cs push cs
push offset @@back push offset .back
push [es:(vector si).data.seg] push [es:si+vector.data.seg]
push [es:(vector si).data.off] push [es:si+vector.data.off]
call savecontext,offset function_reg stdcall savecontext,offset function_reg
call restorecontextg,offset calling_reg stdcall restorecontextg,offset calling_reg
db 0xCB db 0xCB
@@back: .back:
cli cli
call savecontext,offset calling_reg stdcall savecontext,offset calling_reg
call restorecontextg,offset function_reg stdcall restorecontextg,offset function_reg
@@next: .next:
add si,size vector add si,vector.sizeof
dec cl dec cl
jnz @@launchall jnz .launchall
@@end: .end:
ret 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=fasm
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie -I ../include -D__ASSEMBLY__ -c -o CLEAN=rm -rf
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
all: system.sys all: systeme.sys disque.sys video.sys
system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin systeme.sys: systeme.asm
$(BUILD) realmode/setup.bin system.bin zoffset.h system.sys $(ASM) $^
sync
allpiggy.o: piggy.o decompress.o header.o disque.sys: disque.asm
$(LINK) -T allpiggy piggy.o decompress.o header.o $(ASM) $^
voffset.h: system video.sys: video.asm
$(NM) system|$(VOFFSET)>voffset.h $(ASM) $^
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) $@ $^
clean: clean:
make -C realmode clean $(CLEAN) *.sys
$(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

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