Page 1 of 1

a noob Question.. :D

Posted: Sat Nov 26, 2011 9:44 am
by Gioyik
Ok.. well i'm starting creating my OS... following this Doc's.. :P http://www.osdever.net/bkerndev/Docs/title.htm so i finished it but i have a big question that i need answer..

How i can writte a system booting that no use Grub? for example... a code.. for start.asm that be an independient boot start for my os.. and that no use grub... for start... and finally i think that depending of the new code of start.asm how i can compile it for run in a virtual machine o create an image?

Thanks so much... This is a interesting forum.. :P

Excuse me for my English.. My native languaje is Spanish.. :)

Re: a noob Question.. :D

Posted: Sat Nov 26, 2011 10:04 am
by Love4Boobies
This forum comes with a wiki...

Re: a noob Question.. :D

Posted: Sat Nov 26, 2011 3:13 pm
by Tosi
You could write your own bootloader that can boot your own OS.
If you followed the bkerndev tutorial, the kernel should be multiboot-compliant (I'm not sure, I haven't looked at that tutorial in a long time because it has some problems), in which case any other multiboot bootloader could load it. Or, you could use another bootloader and set your kernel up to boot with that.
The first two of these options are heavily documented on the wiki, and the last one is easy to set up given the documentation for the bootloader you want to use is detailed enough.

Re: a noob Question.. :D

Posted: Sat Nov 26, 2011 3:18 pm
by JackScott
The piece of software you're wanting to write is called a bootloader. A boot loader commonly has two stages. The first (called a bootsector) is just responsible for loading the second stage off the hard disk. The first stage can only be 512 bytes in size (on a hard disk or floppy disk). It usually runs in real mode. The second stage is responsible for loading the kernel and other needed files from disk, and for setting up the environment for the kernel (which usually involves switching the CPU to protected or long mode and possibly some other things as required by your kernel).

Assuming you're skilled in assembly language, Love4Boobies' link to the wiki should provide you with most of the information you'll need.

The process of creating an image that can be used in an emulator (or copied to real media and used on real hardware) is fairly OS-specific. You'll find more information in the wiki.

Re: a noob Question.. :D

Posted: Fri Dec 09, 2011 2:47 am
by MihailB
So you want your OS to start without the support of GRUB and other like bootloaders, am I corect ?

In that case what you need is :
- to write your bootsector to MBR [MasterBootRecord]
BUT take care ! MBR contains all the partition information about the drive ! You need to rewrite the bootsector with your own bootsector but PRESERVING the Partition Tables otherwise you will loose your drive !

You should use an USB stick, an OLD harddisk, a virtual drive but never try this on your real computer as long as you are noob ...[otherwise you will distroy your partition tables]

technical part:
the MASTER BOOT RECORD sector stucture :

at byte 0x03 start the boot_sector standard record [after which it maybe the boot_sector_extended record]:

Code: Select all

Type boot_sector Field = 1
        OEM_Identifier(1 To 8) As ubyte 
        BytesPerSector As ushort 
        SectorsPerCluster As UByte
        ReservedSectors As ushort
        NumberOfFATs As ubyte
        RootEntries As ushort
        NumberOfSectors As ushort
        MediaDescriptor As ubyte
        SectorsPerFAT As ushort
        SectorsPerHead As ushort
        HeadsPerCylinder As ushort
        HiddenSectors As UInteger
        BigNumberOfSectors As UInteger
        BigSectorsPerFAT As UInteger
        ExtFlags As UShort
        FSVersion As ushort
        RootDirectoryStart As UInteger
        FSInfoSector As UShort
        BackupBootSector As UShort
End Type
Const boot_sector_ext_16= &h25
Const boot_sector_ext_32= &h41
Type bootsect_ext Field = 1
        BIOS_drive_number As UByte 
        Reserved As UByte
        Extended_Boot_Record_signature As UByte '= 29h 
        Serial_Number As UInteger 
        Volume_label(1 To 11) As ubyte 
        System_Identifier(1 To 2) As UInteger 
End Type 
the partition_tables start at byte : 0x1BE
(1st) partition record at : 0x1BE
(2nd) partition record at : 0x1CE
(3rd) partition record at : 0x1DE
(4th) partition record at : 0x1EE

the partition record :

Code: Select all

Type partition_table Field =1 
   Boot_indicator As ubyte
   Beginning_head_number As ubyte
   Beginning_sector_and_high_cylinder_number As UByte 
   Beginning_low_cylinder_number As UByte 
   System_indicator As UByte 
   Ending_head_number As ubyte 
   Ending_sector_and_high_cylinder_number As ubyte 
   Ending_low_cylinder_number As ubyte
   Number_of_sectors_preceding_the_partition As UInteger 'or LBA start 
   Number_of_sectors_in_the_partition  As UInteger                      'or LBA length
End Type
------------------------------------
A tool that writes a new bootsector to the MBR needs to preserves these records :
boot_sector,boot_sector_extended, partition_tables [1 to 4];
the rest of space is yours !
the first 3 bytes in the sector represents a "jump assembly instruction" to the boot sector code [will make cpu jump over boot_sector record to the boot sector code];
the few next sectors after the MBR are used by the boot_loaders to store additional code
[it can uses up to [partition_table[0].Number_of_sectors_preceding_the_partition]

I once used a tool called BOOTABLE.EXE to safely integrate my own BOOTSECTOR inside the MBR... [but I don't garantee for it; you should read it's docs first]

see ya ! happy coding

Re: a noob Question.. :D

Posted: Fri Dec 09, 2011 11:46 am
by guyfawkes
MihailB wrote: I once used a tool called BOOTABLE.EXE to safely integrate my own BOOTSECTOR inside the MBR... [but I don't garantee for it; you should read it's docs first]
@OP: BOOTABLE.EXE is included in bootprog just google it.