Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any Genius (Guru) out there?Making an OS? Protected mode? Boot sector? 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How do I make a boot sector?
How do I make a protected mode 32 bit kernel???
Can I use interrupts in protected mode???

I need some source to make a boot sector code that jumps to a kernel. That boot sector and kernel must run on diskette.
Must show this:

Starting in Real Mode.

I'm in protected mode. Now Put here your code in assembly with bios interrupts.

Any Guru out there?
 
You can delve linux bootsect.S file for some experience.

Regards! zallen@cmmail.com
Long live of freedom!
 
1) How do I make a boot sector?

^Once your kernel is written, you can use the following command to write it out to a floppy to boot from:

debug <filename>
- w 100 0 0 1
- q

^However, your assembly code would determine where in memory it executes. To become the kernel, it would have to move to address 0000:07C00h. It would look like this:

org 07c00h

2) How do I make a protected mode 32 bit kernel???

^I would suggest reading something like protected mode basics


^To switch to protected mode only requires a few statements but you should understand what you're actually going to encounter before proceeding.

3) Can I use interrupts in protected mode???

^Sure, but not all applications can run in 32 bit protected mode.

4) I need some source to make a boot sector code that jumps to a kernel. That boot sector and kernel must run on diskette.
Must show this:

Starting in Real Mode.


^Real Mode and Protected Mode are not the same. Again, if you are truly interested in learning Assembly Language and/or Protected Mode Programming... You should read publications on the topic.
 
Hey ,
I had written a protected mode boot sector for my
tiny PM OS, i m developing. ( i386+, Flat Model developed gcc, Linux, NASM )
u can find sources in
The boot sector is written in NASM. If u r good in MASM
u can learn it cooly.

The loader is of two stages : First one Loads the
kernel above 1 MB area and loads the second stage
into real memory and jumps into second stage. The second
stage sets up paging and jumps into 1Mb area.
The kernel code is relocated to 3gb so that,
its sits on 0ne end of the process address space.
U can learn lot machine dependant stuff there ( i386 specific ).
Moreover, u also have machine independent code there.
Which basically manages multiple address spaces. This includes management of page-tables and physical pages.

U can also have a look on my tutorial on VM. May
be useful. It might show u a direction of how to proceed
after u come out of machine dependencies.

I have also developed multi-threading of kernel.
(using 386 TSS ). I haven't updated the kernel source there.
I'll do it in a day or two.

Ok,
Happy Adventures

Cheers,
Sarnath.K
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
The boot sectore does not have a special format which the BIOS bootstrap expects, but DOS does expect a special format for the boot sector. The boot sector, technically, is much like a DOS .com file, it is just a plain memory image. It is loaded at absolute 07c0h, or 007c:0000h. However, DOS expects a BPB or BIOS Parameter Block, so the first three bytes of the boot sector must contain a jmp command which jumps over the BPB (and any data you add to the end of the BPB). I can give you the format for the BPB if you are interested.

Setting the processor to Protected Mode is easy, you just set bit 0 of the MSW (80286) or CR0 (80386+) to 1. However, that is like saying getting married is easy, you just say &quot;I do&quot; when the priest asks you if you accept him/her as a spouse. Like marriage, Protected Mode requires preparation and maintanance.

Much of the maintenance work in PM is related to interrupts. You need to trap the interrupts, ESPECIALLY THE IRQ's, since the BIOS (who normally handles the IRQ's) is somewhat ignorant of Protected Mode. Note that there is a BIOS call which sets the computer to PM, and sets up a basic system, but after that the BIOS is -dead-. Much of the work you'll do will be handling the hardware of the computer independent of the BIOS.
&quot;Information has a tendency to be free. Which means someone will always tell you something you don't want to know.&quot;
 
I should correct myself. I typed 0000:07C00h but I should have typed 007c:0000h.
 
Hello boxgo,
u have not corrected urself. Ur previous
notion was correct
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Hello Sarnath,

I saw the AmkG's entry and I thought I had typed mine incorrectly. It was correct the first time 0000:07C00h.

Thanks!
 
All I can say is, Oops, I got caught by a misprint in the manual...

Incidentally, you want your boot code to be less than 1BEh bytes in length (446 decimal bytes). That's because a hard drive's Master Boot Record contains the first partition table at offset 1BEh. What you can do is make the boot code load a few other sectors which would then load your file, instead of forcing the boot file to be on the first few sectors on the disk. Also, if you need to write a boot code to a hard drive, read the MBR first, then modify the first 446 bytes in memory, then write it back.

Also, boot address shouldn't matter too much, largely because 80x86 code is inherently movable (all near calls are relative). &quot;Information has a tendency to be free. Which means someone will always tell you something you don't want to know.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top