1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
Bits 16 ;on passe en 16Bits
%define secteur 1 ; la valeur AL et equivalent a 1 ( secteur )
%define port_clavier_60 60h
jmp Main ; on saut a Main
SectorsPerTrack dw 18
Sides dw 2
Print:
lodsb
cmp al, 0
je Done
mov ah, 0eh
int 10h
jmp Print
Done:
ret
Main:
mov [BootDrive], dl ; recuparation de l'unite de boot
cli ; initialisation des segments
mov ax, 0x07C0
mov ss, ax
mov sp, 0xf000
sti
mov ds, ax
mov es, ax
mov si, msg_kyb ;affiche le msg clavier
call Print ; saut a print pour afficher le msg
mov si, msg_vga ;affiche le msg vide pour sauter un ligne
call Print ; saut a print pour afficher le msg
mov si, msg1 ;affiche le msg pour appuyer sur un touche pour démarrer le systeme
call Print ; saut a print pour afficher le msg
load_root:
int 13h
jnc loaded_root
jmp load_root
mov ch, 0
mov cl, 2
mov dh, 1
mov bx, buffer
mov al, secteur
mov ah, 2
loaded_root:
;hlt
attend_frappe:
mov ah,0
int 16h
xor ax,ax
in al,port_clavier_60
test al,10000000b
jnz attend_frappe ;si on a appuyer sur un touche on continue
popa
mov di, buffer
mov cx, 224
search_root: ; ici on recherche le shell
push cx
pop dx
mov si, filename ; ici ont cherche le nom du shell
mov cx, 11
rep cmpsb
je found_file ; si on trouve le shell on continue
add ax, 32
mov di, buffer
add di, ax
push dx
pop cx
loop search_root
mov si, msg ; si on trouve pas le shell Erreur on affiche le msg Non trouvé
call Print
cli
hlt ; et la on bloque le boot sur le msg
msg db 'Erreur Noyau SxS Non Trouver!',0
msg1 db 'Appuyez sur une touche pour demarrer SxS',10,13,0
msg_kyb db 'Chargement Du Clavier [OK]',10,13,0
msg_vga db '',10,13,0
found_file: ; donc si on trouve le shell on contine
mov ax, WORD [di+15]
mov [FirstSector], ax
mov bx, buffer
mov ax, 1
mov al, 9
mov ah, 2
pusha
load_fat:
int 13h
jnc loaded_fat
jmp load_fat
loaded_fat:
mov ah, 2
mov al, 1
push ax
load_file_sector:
mov ax, WORD [FirstSector]
add ax, 31
mov ax, 2000h
mov es, ax
mov bx, WORD [Pointer]
pop ax
push ax
int 13h
jnc calculate_next_sector ; si on a aucun souci de secteur on continue
jmp load_file_sector
calculate_next_sector: ; on calcule les secteur suivant
mov ax, [FirstSector]
mov dx, 0
mov bx, 6
mul bx
mov bx, 4
div bx
mov si, buffer
add si, ax
mov ax, WORD [si]
or dx, dx
jz even
odd:
shr ax, 4
jmp short next_sector_calculated
even:
and ax, 0FFFh
next_sector_calculated:
mov WORD [FirstSector], ax
cmp ax, 0FF8h
jae end
add WORD [Pointer], 512
jmp load_file_sector
end:
pop ax
mov dl, BYTE [BootDrive] ; on charge le shell
jmp 2000h:0000h ; on demarre le shell
BootDrive db 0
filename db "KERNEL XNO" ; le nom du shell
FirstSector dw 0
Pointer dw 0
times 510 - ($-$$) db 0
buffer:
dw 0xAA55 |
Partager