further development

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
icke
Posts: 5
Joined: Fri Aug 25, 2006 12:44 am

further development

Post by icke »

hi,

i read some tutorials on OS development and got to know how to built a simple kernel, to manage interrupts etc. now i am interessted to improve my "os" and want to add somme stuff i did not find much information about in the web(it seems there is just n00b stuff out there in os dev). this is:
- adding fat32 FS support
- executing binaries/applications (=> ring 3)

how can these things be done? is it quiet difficult is is it doable for a newbie like me (with some time spent on it)....

cu
icke
joke
Member
Member
Posts: 56
Joined: Sat Jul 22, 2006 6:20 am

Post by joke »

Fat is easy , take a look at
http://scottie.20m.com/fat.htm

This should clarify about fat.
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
icke
Posts: 5
Joined: Fri Aug 25, 2006 12:44 am

Post by icke »

this article is quiet interessting, but unfortunatly its just about FAT12, do u now an other article about FAT16 od 32? I'd prefer this because its more common these times.
what about my second aim?

greetz

icke
Legend
Member
Member
Posts: 195
Joined: Tue Nov 02, 2004 12:00 am
Contact:

Post by Legend »

You can apply knowledge about FAT12 to FAT16 and 32, too.
User avatar
chase
Site Admin
Posts: 710
Joined: Wed Oct 20, 2004 10:46 pm
Libera.chat IRC: chase_osdev
Location: Texas
Discord: chase/matt.heimer
Contact:

Post by chase »

Fat 12,16, and 32 are basically the same. The biggest difference is the bit size of the fat entries and Fat 32 has more reserved sectors and a little bit of extra data in them. In my opinion it's more work to add VFat support than adding Fat16 support. Do a google search for "fatgen103", that'll give you all you need.
icke
Posts: 5
Joined: Fri Aug 25, 2006 12:44 am

Post by icke »

thanks for ur help, but still u didn't help me with my second question.
What do i have to do, to get the kernel run an application for my os (sure, the app should not be compatible to linux or windows or whatever - it may just have a simple structure). I think thats a improtant thing for an OS to run applications (maybe a simple notepad or a calculater). What do i need to do for that?
i read a lot of stuff about OS dev the last weeks but i didn't find anything how to get form ring0 to ring3.
joke
Member
Member
Posts: 56
Joined: Sat Jul 22, 2006 6:20 am

Post by joke »

running an application is simple:
1)Read from a floppy (or from a hd) a program to memory
2) Jump to it :D

Of course that is only true for very simple real mode apps. But the basic principle remains the same in pmode. Of course you have to take care of the TSS and protection but you can find all relevant information in intel's manuals.

Best Regards
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
icke
Posts: 5
Joined: Fri Aug 25, 2006 12:44 am

Post by icke »

hmm and how to get to protected mode? and whats the basic difference of both modes?
conner
Posts: 3
Joined: Mon Aug 28, 2006 4:16 am
Location: Denmark, Aalborg

Post by conner »

in real-mode you access memory by segment and offset
the base-address for the segment is calculated segment*0x10 (16)
ex: if you refer to 0x0008:0x0500 you get the linear address 0x0080*0x10+0x0500 = 0x0580

in protected-mode you access memory by selector and offset
the selector refers to an segment descriptor cache, which holds information about the base-address, segment size, permissions and more.
ex: if you refer to 0x0008:0x0500 a segment descriptor will be looked up in the segment descriptor cache, and it might tell that the base address is 0x01000000, so you get the address 0x01000000+0x0500 = 0x0100500.

also some bits in segment descriptor specify privilege, so its possible to make certain parts of memory accesible to kernel (ring0) only, so user applications(ring3) can not mess up kernel data and make system crash.

the segment descriptor cache can e.g. be changed by defining a GDT and using asm instruction lgdt.

in p-mode you can also use paging, which enables you to have a virtual address space you can map to the physical memory as desired and also makes it possible to implement demand-paging where data is brought into memory from disk when needed (but forget about that for now).

more about p-mode:
http://www.osdever.net/tutorials/pm.php?the_id=16

remember also to enable a20 gate to access memory above 1mb
http://www.win.tue.nl/~aeb/linux/kbd/A20.html

Intel System Programming (a must read!)
ftp://download.intel.com/design/Pentium ... 319202.pdf
joke
Member
Member
Posts: 56
Joined: Sat Jul 22, 2006 6:20 am

Post by joke »

Other differences are:
In real mode you can address only up to 1Mib of memory while in pmode up to 4 GiB ( or even 64GiB)
In real mode you have BIOS interrupts
no protection in real mode
The hole memory is segmented in 64k segments if you like it or not
in pmode
no BIOS help
you have to worry about Protection
everything is indexed through tables
you use segmentation the way you like
the very basic pmode structure is the Global Descriptor Table (GDT) cause it contains all descriptors your system needs for basic operation.
For example if you need X segments you define them in there
Btw there are other modes too like unreal mode which is like real mode but you can address more memory (that's really cool 8))
and ia-32e mode (for 64 bits :wink: )
Best Regards
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
icke
Posts: 5
Joined: Fri Aug 25, 2006 12:44 am

Post by icke »

Thanks a lot for your replies. But a few questions are left.
Is it possible to mix realmode and proteceted mode (e.g. run the kernel in realmode and the rest in pmode?)? If yes, is it common to do so? (Does it make sense at all?)
If I cannot use the bios interrupts in pmode, how to get the given functionally of these interrupts this way (e.g. video-stuff).

Another point: Afaik ring0 is the "memory" the kernel is running is, and ring3 is a layer all apps are running. Ring0 can access Ring3, but not the other way around (I mean the memory). I think its common to use Interrupts for sending commands from ring3 to ring0. Are there also other possibilities? And how to setup the Ring0/Ring3 - gap?

regards,

icke
User avatar
kenneth_phough
Member
Member
Posts: 106
Joined: Sun Sep 18, 2005 11:00 pm
Location: Williamstown, MA; Worcester, MA; Yokohama, Japan
Contact:

Post by kenneth_phough »

icke wrote:Is it possible to mix realmode and proteceted mode (e.g. run the kernel in realmode and the rest in pmode?)? If yes, is it common to do so? (Does it make sense at all?)
No, you can't mix the two. They are modes that the CPU runs in so once you enter a mode, all instructions are executed in that mode.
icke wrote:If I cannot use the bios interrupts in pmode, how to get the given functionally of these interrupts this way (e.g. video-stuff).
You can try Virtual 8086 mode. Unfotunately, I don't seem to be able to find a site on how to implement virtual 8086 mode but you can find a detail description on it in the IA-32 Intel Architecture Software Developer's Manual Volume 3A; Chapter 15.
Also this is a site on what virtaul 8086 mode is:
http://en.wikipedia.org/wiki/Virtual_8086_mode

Hope this helps :wink:
Kenneth
Post Reply