load & execute next sector after bootsector

Programming, for all ages and all languages.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: load & execute next sector after bootsector

Post by onlyonemac »

bilsch01 wrote:The command lines for writing them to disk are:

dd if=/mnt/sda5/home/bilsch/jinx/bootn1.bin count=1 of=/dev/sda1 count=1
dd if=/mnt/sda5/home/bilsch/jinx/kern1.bin count=1 of=/dev/sda1 seek=1 count=1
If you're using "count=1", you need to specify a block size and make sure that the files are smaller than the block size otherwise they will be truncated.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: load & execute next sector after bootsector

Post by iansjack »

dd uses a default block size of 512 bytes.
bilsch01
Member
Member
Posts: 42
Joined: Sat Dec 19, 2015 10:48 am

Re: load & execute next sector after bootsector

Post by bilsch01 »

Have you confirmed that /dev/sda1 starts at LBA 1 and not somewhere else?
[/quote]Hint: it probably doesn't.[/quote]

Yes. I corrected that. Sector to load is lba 64 not lba 2. I have the program running correctly now - Success. Onwards to writing a real bootsector and a format program. I,m going to model it on MSDOS. Thanks for your help. Bill S.
Last edited by bilsch01 on Tue Apr 19, 2016 5:08 pm, edited 1 time in total.
bilsch01
Member
Member
Posts: 42
Joined: Sat Dec 19, 2015 10:48 am

Re: load & execute next sector after bootsector

Post by bilsch01 »

onlyonemac wrote:
bilsch01 wrote:The command lines for writing them to disk are:

dd if=/mnt/sda5/home/bilsch/jinx/bootn1.bin count=1 of=/dev/sda1 count=1
dd if=/mnt/sda5/home/bilsch/jinx/kern1.bin count=1 of=/dev/sda1 seek=1 count=1
If you're using "count=1", you need to specify a block size and make sure that the files are smaller than the block size otherwise they will be truncated.
Both files are 512 bytes. Default bs is 512.
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: load & execute next sector after bootsector

Post by iansjack »

bilsch01 wrote:I corrected that. Sector to load is lba 64 not lba 2. I have the program running correctly now - Success. Onwards to writing a real bootsector and a format program.
You really shouldn't hard code this value. Read the partition table to find where the partition starts.
Post Reply