Why doesn't the bootloader completely?

69 views Asked by At

I’m trying to load resources, but it doesn’t load (?) It can fully answer what exactly is happening to it, it doesn’t give errors, but it doesn’t work like that, it doesn’t respond to the command, it just outputs, while the entor entered what. This behavior manifested itself after the value of the coefficient increased.

dumpbin when the kernel was running:

SECTION HEADER #1
   .text name
    3FE1 virtual size
    1000 virtual address (00011000 to 00014FE0)
    4000 size of raw data
     400 file pointer to raw data (00000400 to 000043FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000020 flags
         Code
         Execute Read

SECTION HEADER #2
   .data name
    1046 virtual size
    5000 virtual address (00015000 to 00016045)
     200 size of raw data
    4400 file pointer to raw data (00004400 to 000045FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0000040 flags
         Initialized Data
         Read Write

SECTION HEADER #3
.data/IG name
    1E90 virtual size
    7000 virtual address (00017000 to 00018E8F)
    2000 size of raw data
    4600 file pointer to raw data (00004600 to 000065FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

dumpbin, after I added a function to the kernel that counts ticks, after it the kernel itself increased and stopped working correctly :

SECTION HEADER #1
   .text name
    4031 virtual size
    1000 virtual address (00011000 to 00015030)
    4200 size of raw data
     400 file pointer to raw data (00000400 to 000045FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000020 flags
         Code
         Execute Read

SECTION HEADER #2
   .data name
    1046 virtual size
    6000 virtual address (00016000 to 00017045)
     200 size of raw data
    4600 file pointer to raw data (00004600 to 000047FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0000040 flags
         Initialized Data
         Read Write

SECTION HEADER #3
.data/IG name
    1E90 virtual size
    8000 virtual address (00018000 to 00019E8F)
    2000 size of raw data
    4800 file pointer to raw data (00004800 to 000067FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

загрузка ядра

use16
org 0x7C00
start:
mov ax, cs 
mov ds, ax  
mov ss, ax 
mov sp, start  

mov ax, cs 
mov ds, ax  
mov ss, ax 
mov sp, start 

mov ax, 0x1100
mov es, ax
mov bx, 0x0000
mov dl, 1 
mov dh, 0 
mov ch, 0 
mov cl, 3
mov al, 33
mov ah, 0x02 
int 0x13

mov ax, 0x1600
mov es, ax
mov bx, 0x0000
mov dl, 1
mov dh, 0
mov ch, 0
mov cl, 36
mov al, 1
mov ah, 0x02

int 0x13
mov ah, 0
mov al, 2
int 0x10

mov ax, 0x1800
mov es, ax
mov bx, 0x0000
mov dl, 1
mov dh, 0
mov ch, 0
mov cl, 37
mov al, 16
mov ah, 0x02
int 0x13 

  lgdt [gdt_info]
in al, 0x92
or al, 2
out 0x92, al    
mov eax, cr0
or al, 1
mov cr0, eax
jmp 0x8:protected_mode 
gdt:
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
;base=0, size=4Gb, P=1, DPL=0, S=1(user),
;Type=1(code), Access=00A, G=1, B=32bit
db 0xff, 0xff, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
;base=0, size=4Gb, P=1, DPL=0, S=1(user),
;Type=0(data), Access=0W0, G=1, B=32bit
db 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
gdt_info: 
dw gdt_info - gdt
dw gdt, 0
use32
protected_mode:
mov ax, 0x10
mov es, ax
mov ds, ax
mov ss, ax
call 0x11000
times (512 - ($ - start) - 2) db 0 
db 0x55, 0xAA   

function that reads ticks

__declspec(naked) void timer()
{
    __asm pusha;
    ticks++;
    outb(PIC1_PORT, 0x20);
    __asm {
        popa
        iretd
    }
}

void init_ticks(){
    intr_reg_handler(8, GDT_CS, 0x80 | IDT_TYPE_INTR, timer); // Регистрация обработчика прерывания (segm_sel=0x8, P=1, DPL=0, Type=Intr)
    outb(PIC1_PORT + 1, 0xFF ^ 0x01);
    }

Translator: FASM, assembler: Intel, compiler: ms c

i try load correct data in bootloader but it still doesnt work

0

There are 0 answers