ATAPI driver reads nothing

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
DeletedAccount2431
Posts: 10
Joined: Thu Feb 13, 2020 1:06 am

Re: ATAPI driver reads nothing

Post by DeletedAccount2431 »

Code: Select all

xorriso -as mkisofs -R -J \
      -b disk.img -no-emul-boot -boot-load-size 1 \
      -o mybootcd2.iso cd_img
i've changed command for creating iso so am i able to have binary size more than 2880 kbs?
also, i cant make my code working normally when i read it from iso by myself from 34 sector where my code is located at drive
it works but instead of printing string it prints some strange symbols and cant load GDT saying "fetch_raw_descriptor: GDT: index (f) 1 > limit (0)" (when i load code by int 13, ah=0x2 it works normally without any errors)

but dumps of memory where i load stage 2 absolutely identical (except of in second case i also load my stage1 (512 bytes) to memory so i simply add 0x200 to start address in memory) and i dont know what to do with that

Code: Select all

load_disk_lba :
     push ax
     push si 
     mov ah, 0x42
     mov si, lba_read_packet
     mov byte [lba_read_packet], 0x10
     mov word [lba_read_packet + 2], cx
     mov word [lba_read_packet + 4], di
     mov word [lba_read_packet + 6], ds
     mov word [lba_read_packet + 8], bx
     int 0x13
     jc disk_error
     pop si 
     pop ax
     ret
disk_error : 
      jmp $
align 8
lba_read_packet times 16 db 0

Code: Select all

load_kernel : 
   push ds
   pusha
   mov dl, [BOOT_DRIVE]
   xor ax, ax
   mov ds, ax
   mov es, ax
   mov di, 0x1000
   mov bl, 0x22
   mov cx, 0x3
   call load_disk_lba
   popa 
   pop ds
   ret  
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: ATAPI driver reads nothing

Post by Octocontrabass »

alicedeveloper wrote:i've changed command for creating iso so am i able to have binary size more than 2880 kbs?
Yes, but you could have done that anyway by telling the BIOS to stop floppy disk emulation.
alicedeveloper wrote:also, i cant make my code working normally when i read it from iso by myself from 34 sector where my code is located at drive
it works but instead of printing string it prints some strange symbols and cant load GDT saying "fetch_raw_descriptor: GDT: index (f) 1 > limit (0)" (when i load code by int 13, ah=0x2 it works normally without any errors)

but dumps of memory where i load stage 2 absolutely identical (except of in second case i also load my stage1 (512 bytes) to memory so i simply add 0x200 to start address in memory) and i dont know what to do with that
It sounds like your code needs to run at a specific address, and you're running it at an address 512 bytes higher. It could also be caused by bad assumptions about the value of segment registers (especially CS).
DeletedAccount2431
Posts: 10
Joined: Thu Feb 13, 2020 1:06 am

Re: ATAPI driver reads nothing

Post by DeletedAccount2431 »

It sounds like your code needs to run at a specific address, and you're running it at an address 512 bytes higher. It could also be caused by bad assumptions about the value of segment registers (especially CS).
thank you very much ! i've changed value in linker command from 0x100000 to 0x100200 and now my stage 2 works ! also i've changed value in linker command for kernel and it works too !

now i know more possible solutions for new problems and understand why my atapi driver works different from as it was intended

thank you again !
Post Reply