0

I have a bootloader and a kernel both written in assembly.

Now I have two issues with these files. As the size of the bootloader is 512B, I am able to successfully run the .img file of the bootloader in VirtualBox.

But:

  1. The size of the Kernel is 580B and it is not accepted by the VirtualBox floppy drive. How to I come out of this? That is Running the kernel in VirtualBox.
  2. How do I transfer control to the kernel part from the bootloader?

And I am in a Windows 7 environment.

Dan Fego
  • 13,644
  • 6
  • 48
  • 59
  • Can Somebody reply me in here? Plz! – user3803670 Jul 04 '14 at 14:25
  • The floppy image needs to be a multiple of the sector size, which is 512 bytes. And, just a forewarning, only the first 512 bytes will get loaded into memory; you'll have to write your own code that loads the rest of the floppy image. – Drew McGowen Jul 09 '14 at 21:26

2 Answers2

0

1-)Make it ISO Image Using MISO

 miso my.iso -ab my.img

(you have to copy them into one img file using copy /b)

2-)I didn't totally understand it but I will help you as possible as i can. I think you want call some code part inside of bootloader,from kernel. As you know,you have to know memory adress of your code which do you want to call or you can use .inc file to call this part of code.If you want to make kernel be able to access bootloader's memory segment in runtime,like my first advise you have to know memory adress of code you want to call it Like:

[Bits 16]
[ORG 0x7c00]
start:
...
times 256-($-$$) db 0
blbla:;I know that is in the [0x7d00]
jmp $
times 256-($-$$) db 0
dw 0xAA55

Feel free to ask me questions : afcultraos@gmail.com

Srs
  • 36
  • 6
0

For first part add a line at the end of the kernel code -
...

no_of_sectors equ 8
times 512*no_of_sectors db 0

Change the number to fix the size according to sectors.

For second - you can load the kernel into memory using interrupt 13h

loading_kernel:
mov bx,0x1000 ;where_to_load_kernel
mov dl,128 ;DRIVE_NUMBER commonly 128 for HDD and 0 for floppy
mov dh,0 ;head_no - at starting its 0
mov ah,0x02 ;Read sectors function in BIOS
mov al,0x12
mov cx,0x0002 ; No of sectors to read
int 13h ; BIOS interrupt - only use in real mode

jc loading_kernel ;In case of error retry
jmp 0x1000 ;then you can simply jump to the kernel code

Divyavrat
  • 56
  • 6