; kernLdr_init.asm - This file is a part of NutsOS ; NutsOS ; Copyright (C) 2013 Free Software Foundation, Inc. ; NutsOS is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 3 of the License, or ; (at your option) any later version. ; NutsOS is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should have received a copy of the GNU General Public License along ; with NutsOS; If not, see . ; Valentin Verdier [BITS 32] [SECTION .text] global kernLdr_init extern kernLdr_main kernldr_init: ; On initialise tous les segments de données pour le mode protégé mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax ; Segment de pile mov ax, 0x18 mov ss, ax mov esp, 0xA0000 ; Pile à 0xA0000 push eax ; on vérifie que la ligne a20 est activée call check_a20_line cmp eax, 0 je .next ; Si activée, on passe call enable_a20_line ; Sinon on l'active .next: ; On appel le fonction principale qui : ; - calcul la taille de la mémoire utilisable à partir de la liste de plage mémoire communiquée par kernldr_1 ; - charge la partition FAT32 définit ; - charge KERNEL32 à l'adresse 0x100000, et init à l'adresse 0x28000 depuis le répertoire /boot ; - construit la structure de passage d'argument call kernldr_main ; On saute vers le kernel mov esp, 0xA0000 jmp 0x08:0x100000 ; Retourne 0xFFFFFFFF si déactivée, 0 si activée check_a20_line: mov dword [0x500], 0 mov dword [0x100500], 0xFFFFFFFF mov eax, [0x500] ret enable_a20_line: push eax in al, 0x92 test al, 0x02 jnz .end or al, 0x02 and al, 0xFE out 0x92, al .end: pop eax ret