further development
further development
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
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
- 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:
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.
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.
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.
running an application is simple:
1)Read from a floppy (or from a hd) a program to memory
2) Jump to it
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
1)Read from a floppy (or from a hd) a program to memory
2) Jump to it
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
I cant see the things that make true happiness, I must be blind
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
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
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 )
and ia-32e mode (for 64 bits )
Best Regards
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 )
and ia-32e mode (for 64 bits )
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
I cant see the things that make true happiness, I must be blind
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
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
- kenneth_phough
- Member
- Posts: 106
- Joined: Sun Sep 18, 2005 11:00 pm
- Location: Williamstown, MA; Worcester, MA; Yokohama, Japan
- Contact:
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: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?)
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.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).
Also this is a site on what virtaul 8086 mode is:
http://en.wikipedia.org/wiki/Virtual_8086_mode
Hope this helps
Kenneth