Writing BootSector & Kernel
Writing BootSector & Kernel
I have made a very basic bootloader that loads my very basic kernel, but I am having a lot of trouble writing it the floppy, I have tried with copyboot, but that hasn't worked. Any suggestions?
EDIT: I got the bootloader to work using copyboot, but now when I try to write the kernel to the floppy, the disk needs to be formatted, which gets me back to the start...
EDIT: I got the bootloader to work using copyboot, but now when I try to write the kernel to the floppy, the disk needs to be formatted, which gets me back to the start...
NULL
- matias_beretta
- Member
- Posts: 101
- Joined: Mon Feb 26, 2007 3:39 pm
use debug (MS-DOS)
> format a:
> debug kernel.bin ;FIRST KERNEL
w 100 0 1 1
> debug boot.bin ;SECOND BOOT
w 100 0 0 1
> debug kernel.bin ;FIRST KERNEL
w 100 0 1 1
> debug boot.bin ;SECOND BOOT
w 100 0 0 1
MatÃas Beretta
Re: use debug (MS-DOS)
Hmm... Debug isn't working properly. After I enter w 100 0 1 1, it just keeps asking for more input.matias_beretta wrote:> format a:
> debug kernel.bin ;FIRST KERNEL
w 100 0 1 1
> debug boot.bin ;SECOND BOOT
w 100 0 0 1
NULL
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
In cygwin:
Code: Select all
dd if=floppy.img of=/dev/fd0
- matias_beretta
- Member
- Posts: 101
- Joined: Mon Feb 26, 2007 3:39 pm
reply
i'm sorry i forgot 'q'
> format a:
> debug kernel.bin ;FIRST KERNEL
w 100 0 1 1
q
> debug boot.bin ;SECOND BOOT
w 100 0 0 1
q
> format a:
> debug kernel.bin ;FIRST KERNEL
w 100 0 1 1
q
> debug boot.bin ;SECOND BOOT
w 100 0 0 1
q
MatÃas Beretta
It depends on how your loader loads stuff off the disk, but if your geting the format error you need to include something like this in your boot sector
Also try "partcopy" you will find it on the net.
Code: Select all
use16
org 0x7C00
boot: jmp near start
nop
;------------------------------------------;
; Standard BIOS Parameter Block, "BPB". ;
;------------------------------------------;
bpbOEM db 'MY OS'
bpbSectSize dw 512
bpbClustSize db 1
bpbReservedSec dw 1
bpbFats db 2
bpbRootSize dw 224
bpbTotalSect dw 2880
bpbMedia db 240
bpbFatSize dw 9
bpbTrackSect dw 18
bpbHeads dw 2
bpbHiddenSect dd 0
bpbLargeSect dd 0
;---------------------------------;
; extended BPB for FAT12/FAT16 ;
;---------------------------------;
bpbDriveNo db 0
bpbReserved db 0
bpbSignature db 41 ; 0 = nothing more. 41 = three more (below)..
bpbID dd 1
bpbVolumeLabel db 'BOOT FLOPPY'
bpbFileSystem db 'FAT12 '
;----------------------------------------;
; starting point of bootsector code ;
;----------------------------------------;
start:
Well, this is what I have.
But where would I add the code that you gave? All this bootloader does is load my kernel.
Code: Select all
KERNEL_START equ 1 ; Disk block where kernel starts
KERNEL_SIZE equ 1 ; Kernel size in disk blocks
KERNEL_SEGMENT equ 1000h ; Segment where kernel will be loaded
; Load kernel
mov ax, 200h + KERNEL_SIZE
push word KERNEL_SEGMENT
pop es
xor bx, bx
mov cx, KERNEL_START + 1
mov dx, 0
int 13h
jnc ok
jmp $
ok:
; Jump to kernel
jmp KERNEL_SEGMENT:0
; Boot signature
times 510 - ($ - $$) db 0
db 55h
db 0aah
NULL
Re: reply
Ahh, yes, after fumbling around with it I figured that out and it works, great, now, I have to figure out how to make a batch file that can do that...matias_beretta wrote:i'm sorry i forgot 'q'
> format a:
> debug kernel.bin ;FIRST KERNEL
w 100 0 1 1
q
> debug boot.bin ;SECOND BOOT
w 100 0 0 1
q
NULL
Re: reply
Hi,
Cheers,
Brendan
Sounds like you need something like RawWrite (Microsoft OSs can't do it without additional utilities)...Bobalandi wrote:Ahh, yes, after fumbling around with it I figured that out and it works, great, now, I have to figure out how to make a batch file that can do that...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
- matias_beretta
- Member
- Posts: 101
- Joined: Mon Feb 26, 2007 3:39 pm
reply
not afaik, because the debug commands are inside debug.com and is not a part of ms-dos
MatÃas Beretta
You could try this:
Assemble the lot as a bin file and use rawrite like this
c:\rawrite test.bin a:
Code: Select all
KERNEL_START equ 1 ; Disk block where kernel starts
KERNEL_SIZE equ 1 ; Kernel size in disk blocks
KERNEL_SEGMENT equ 1000h ; Segment where kernel will be loaded
use16
org 0x7C00
boot: jmp near start
nop
;------------------------------------------;
; Standard BIOS Parameter Block, "BPB". ;
;------------------------------------------;
bpbOEM db 'MY OS'
bpbSectSize dw 512
bpbClustSize db 1
bpbReservedSec dw 1
bpbFats db 2
bpbRootSize dw 224
bpbTotalSect dw 2880
bpbMedia db 240
bpbFatSize dw 9
bpbTrackSect dw 18
bpbHeads dw 2
bpbHiddenSect dd 0
bpbLargeSect dd 0
;---------------------------------;
; extended BPB for FAT12/FAT16 ;
;---------------------------------;
bpbDriveNo db 0
bpbReserved db 0
bpbSignature db 41 ; 0 = nothing more. 41 = three more (below)..
bpbID dd 1
bpbVolumeLabel db 'BOOT FLOPPY'
bpbFileSystem db 'FAT12 '
;----------------------------------------;
; starting point of bootsector code ;
;----------------------------------------;
start:
; Load kernel
mov ax, 200h + KERNEL_SIZE
push word KERNEL_SEGMENT
pop es
xor bx, bx
mov cx, KERNEL_START + 1
mov dx, 0
int 13h
jnc ok
jmp $
ok:
; Jump to kernel
jmp KERNEL_SEGMENT:0
; Boot signature
times 510 - ($ - $$) db 0
db 55h
db 0aah
;PUT YOUR SECOND STAGE HERE *********************************
c:\rawrite test.bin a: