OSDev.org

The Place to Start for Operating System Developers
It is currently Mon May 20, 2024 5:52 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Asking further directions
PostPosted: Mon May 26, 2008 1:36 pm 
Offline
Member
Member

Joined: Sat May 24, 2008 12:41 pm
Posts: 41
Location: La Plata, Argentina
I successfully wrote a FAT12 boot sector on a disk and i'm writing the disk reading routines now. Since I'm new on this i would like to see some opinions on the route of my first toy OS:

1) What do you think it's easier? Going 16-bit RM or 32-bit PM? If going to PM32 want to create some form of 'Protected Mode DOS' where all code runs in ring 0. Sure, if all code runs in Ring 0 what is the benefit of PM at all? Well, no 1MB limit and segment mess, easier to code I think.

2) When switching to PM, how do you access to disk using Int 13 (since BIOS calls are not available from PM)?

3) And this is bizarre, what about creating some 16-bit Real Mode multitasking OS, trying to remain into the limitations of the 8086/88 programming model? This sounds like a good programming project.

Thank you very much.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 2:01 pm 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
Hi,

Quote:
1) What do you think it's easier? Going 16-bit RM or 32-bit PM? If going to PM32 want to create some form of 'Protected Mode DOS' where all code runs in ring 0. Sure, if all code runs in Ring 0 what is the benefit of PM at all? Well, no 1MB limit and segment mess, easier to code I think.


32-bit PM (as opposed to 16 bit RM) is a dual-edged sword. On the one hand you get to access all the processor functionality which you can't in real mode - different segment stuff, 32-bit address space, paging etc etc.

However with that, as you've correctly stated, you cannot use BIOS routines (without a vm86 task). IMHO if you're looking for a "protected mode DOS", I really think you should stick with 32-bit "unreal" mode, where you can access the full 4GB and use BIOS routines (but can't use paging).

Quote:
2) When switching to PM, how do you access to disk using Int 13 (since BIOS calls are not available from PM)?


You can call Int 13 by creating a vm86 task - that is, a special task that runs in 16 bit mode. It is, however, incredibly slow, so it is normal procedure to write your own ATA driver once you get into PMode. This is a reason why I personally think you'd be better off with unreal mode, as for what you wish to do it sounds the easiest route.

Quote:
3) And this is bizarre, what about creating some 16-bit Real Mode multitasking OS, trying to remain into the limitations of the 8086/88 programming model? This sounds like a good programming project.


That is definately possible, you don't have to use the hardware assisted method of task switching - you can do cooperative context switching instead. I'm sure Dex can expand on this, as generally I'm a 32-bit protected mode "type" ;)

Hope this helps,

James

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 2:18 pm 
Offline
Member
Member

Joined: Sat May 24, 2008 12:41 pm
Posts: 41
Location: La Plata, Argentina
Well Unreal mode sounds well for my project. Please clarify me on the addressing scheme of Unreal (since I could not find much documentation on it).

On real mode, for a linear address SEG:OFFSET where SEG and OFFSET are 16 bits wide.

PHYSICAL_ADDR = SEG << 4 + OFFSET

So, this addressing scheme actually works EQUAL in Unreal mode but using 32-bit offsets?

SEG << 4 + OFFSET_32

But this means that I can set CS,DS,ES,FS,GS to 0 and use OFFSET_32 as a physical address? This is better than switching to V86 for my needs. :roll:

Thanks!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 2:26 pm 
Offline
Member
Member
User avatar

Joined: Mon Apr 28, 2008 12:14 pm
Posts: 61
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime
indiocolifa wrote:
1) What do you think it's easier? Going 16-bit RM or 32-bit PM? If going to PM32 want to create some form of 'Protected Mode DOS' where all code runs in ring 0. Sure, if all code runs in Ring 0 what is the benefit of PM at all? Well, no 1MB limit and segment mess, easier to code I think.

You're right, PM is better because of no memory limitations. However, it may be difficult in the beginning, because you have to correctly set up stuff like GDT, LDT, IDT, TSS, paging etc. You see how many people on this forum have trouble with this. But after you have done it, and your OS kernel works well and reliably, programming the rest becomes a lot easier.

What's more, it's nearly impossible to write a modern graphical user interface under 16bitRM, because you can't access video memory properly.

indiocolifa wrote:
2) When switching to PM, how do you access to disk using Int 13 (since BIOS calls are not available from PM)?

If you want to use Int13, you have to create a V86 task and call Int13 from there. Or it is also possible to switch back to realmode every time you need disk access. Windows 95 actually did something like that, AFAIK.

And of course, the solution might be to create your own disk drivers, but it ain't the simplest task to do. That's how it's done in real systems.

indiocolifa wrote:
3) And this is bizarre, what about creating some 16-bit Real Mode multitasking OS, trying to remain into the limitations of the 8086/88 programming model? This sounds like a good programming project.

Yes, such projects exist.
Well, in RM there can be no proper multitasking with protected address spaces and privileges. However, in this case it's quite possible to implement multithreading.

Multithreading in Real Mode is achieved using timer IRQ0, which loads context (saved CPU registers' values) and transfers control to another thread at every timer tick. As you can see, it is preemptive sort of multithreading. Naturally, there are many problems with such a system (threads may conflict with each other, trying to access the same device, for example). But it's still a good programming project, because it requires a good deal of thinking and is actually possible.

So, as you can see, it's up to you to choose. Possibilities are endless.

Cheers,
CmpXchg


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 2:38 pm 
Offline
Member
Member
User avatar

Joined: Mon Apr 28, 2008 12:14 pm
Posts: 61
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime
indiocolifa wrote:
But this means that I can set CS,DS,ES,FS,GS to 0 and use OFFSET_32 as a physical address? This is better than switching to V86 for my needs. Rolling Eyes

Exactly!
Code:
xor ax,ax
mov ds,ax
mov word [ds:0B8000h],8403h  ;print a char on screen, but only in Unreal Mode


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 3:07 pm 
Offline
Member
Member

Joined: Sat May 24, 2008 12:41 pm
Posts: 41
Location: La Plata, Argentina
CmpXchg wrote:
indiocolifa wrote:
1) What do you think it's easier? Going 16-bit RM or 32-bit PM? If going to PM32 want to create some form of 'Protected Mode DOS' where all code runs in ring 0. Sure, if all code runs in Ring 0 what is the benefit of PM at all? Well, no 1MB limit and segment mess, easier to code I think.

You're right, PM is better because of no memory limitations. However, it may be difficult in the beginning, because you have to correctly set up stuff like GDT, LDT, IDT, TSS, paging etc. You see how many people on this forum have trouble with this. But after you have done it, and your OS kernel works well and reliably, programming the rest becomes a lot easier.

What's more, it's nearly impossible to write a modern graphical user interface under 16bitRM, because you can't access video memory properly.

indiocolifa wrote:
2) When switching to PM, how do you access to disk using Int 13 (since BIOS calls are not available from PM)?

If you want to use Int13, you have to create a V86 task and call Int13 from there. Or it is also possible to switch back to realmode every time you need disk access. Windows 95 actually did something like that, AFAIK.

And of course, the solution might be to create your own disk drivers, but it ain't the simplest task to do. That's how it's done in real systems.

indiocolifa wrote:
3) And this is bizarre, what about creating some 16-bit Real Mode multitasking OS, trying to remain into the limitations of the 8086/88 programming model? This sounds like a good programming project.

Yes, such projects exist.
Well, in RM there can be no proper multitasking with protected address spaces and privileges. However, in this case it's quite possible to implement multithreading.

Multithreading in Real Mode is achieved using timer IRQ0, which loads context (saved CPU registers' values) and transfers control to another thread at every timer tick. As you can see, it is preemptive sort of multithreading. Naturally, there are many problems with such a system (threads may conflict with each other, trying to access the same device, for example). But it's still a good programming project, because it requires a good deal of thinking and is actually possible.

So, as you can see, it's up to you to choose. Possibilities are endless.

Cheers,
CmpXchg


What are you trying to say with "can't access video memory properly" in 16bit RM? Can't you write to video memory addressing the proper address space where it's mapped?

thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 3:14 pm 
Offline
Member
Member

Joined: Sat May 24, 2008 12:41 pm
Posts: 41
Location: La Plata, Argentina
Maybe what you're saying is that in 16 bit RM only the first 64K VGA address space is available, but in higher video modes which require 128Kr 256k or more you must use some banking or segment-twiddling techniques due to the 64K segment size.

That's it? :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 3:16 pm 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
Quote:
What are you trying to say with "can't access video memory properly" in 16bit RM? Can't you write to video memory addressing the proper address space where it's mapped?

thanks!


Well, look at it this way. In 16 bit mode, you have access to 1MB of addressable space. A 1024x768x32 framebuffer takes 3.145MB of space.

To use a crude American expression which I hope I never use again: "Go figure" ;)

Cheers,

James

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 3:26 pm 
Offline
Member
Member

Joined: Sat May 24, 2008 12:41 pm
Posts: 41
Location: La Plata, Argentina
This applies only to 16bit RM ... I wonder if it's possible to access a linear framebuffer in unreal mode. Anyway, this is not a priority now in my research kernel of course. I should get FAT12 I/O first! :lol:


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 3:31 am 
Offline
Member
Member
User avatar

Joined: Mon Apr 28, 2008 12:14 pm
Posts: 61
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime
JamesM wrote:
Quote:
What are you trying to say with "can't access video memory properly" in 16bit RM? Can't you write to video memory addressing the proper address space where it's mapped?

thanks!


Well, look at it this way. In 16 bit mode, you have access to 1MB of addressable space. A 1024x768x32 framebuffer takes 3.145MB of space.

To use a crude American expression which I hope I never use again: "Go figure" Wink


Couldn't've said it better myself! 8)

indiocolifa wrote:
This applies only to 16bit RM ... I wonder if it's possible to access a linear framebuffer in unreal mode. Anyway, this is not a priority now in my research kernel of course. I should get FAT12 I/O first! Laughing

You're right again. In Unreal mode it there will be no problems accessing the framebuffer.

Buy the way, does you OS load from floppy?


Top
 Profile  
 
 Post subject: Re: Asking further directions
PostPosted: Tue May 27, 2008 4:25 am 
Offline
Member
Member

Joined: Tue May 06, 2008 9:32 am
Posts: 87
Location: The Netherlands
indiocolifa wrote:
I successfully wrote a FAT12 boot sector on a disk and i'm writing the disk reading routines now. Since I'm new on this i would like to see some opinions on the route of my first toy OS:

1) What do you think it's easier? Going 16-bit RM or 32-bit PM? If going to PM32 want to create some form of 'Protected Mode DOS' where all code runs in ring 0. Sure, if all code runs in Ring 0 what is the benefit of PM at all? Well, no 1MB limit and segment mess, easier to code I think.


16-bit RM is much easier because you have full access to the BIOS and you memory management is very simple.
32-bit PM requires direct access to the hardware with everythinkg you do and memory management is more complicated, aspecially when you use paging.

Making a kind of DOS? The design of DOS sucks, it's historic, it doesn't mike sense anymore imo. Think about something new.

Quote:
3) And this is bizarre, what about creating some 16-bit Real Mode multitasking OS, trying to remain into the limitations of the 8086/88 programming model? This sounds like a good programming project.

Thank you very much.


Doesn't sound good to me. 16-bit realmode is a pre-historic thing. I think it's crazy x86 processors still have it. Serious OS-projects on ordinary hardware are 32-bit or 64-bit, not using any segmented memory and using paging.


Top
 Profile  
 
 Post subject: Re: Asking further directions
PostPosted: Tue May 27, 2008 4:58 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
svdmeer wrote:
indiocolifa wrote:
I successfully wrote a FAT12 boot sector on a disk and i'm writing the disk reading routines now. Since I'm new on this i would like to see some opinions on the route of my first toy OS:

1) What do you think it's easier? Going 16-bit RM or 32-bit PM? If going to PM32 want to create some form of 'Protected Mode DOS' where all code runs in ring 0. Sure, if all code runs in Ring 0 what is the benefit of PM at all? Well, no 1MB limit and segment mess, easier to code I think.


16-bit RM is much easier because you have full access to the BIOS and you memory management is very simple.
32-bit PM requires direct access to the hardware with everythinkg you do and memory management is more complicated, aspecially when you use paging.

Making a kind of DOS? The design of DOS sucks, it's historic, it doesn't mike sense anymore imo. Think about something new.

Quote:
3) And this is bizarre, what about creating some 16-bit Real Mode multitasking OS, trying to remain into the limitations of the 8086/88 programming model? This sounds like a good programming project.

Thank you very much.


Doesn't sound good to me. 16-bit realmode is a pre-historic thing. I think it's crazy x86 processors still have it. Serious OS-projects on ordinary hardware are 32-bit or 64-bit, not using any segmented memory and using paging.



* JamesM prepares the popcorn for the Dex-based bitchslapping that is about to commence.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 5:05 am 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 3:03 am
Posts: 1029
Location: Hobart, Australia
/me stocks up on Coke and Chocolate-coated icecreams.

Edit: To say DOS is crap is a pretty big statement. It served the needs of millions of users for a decade.

_________________
My Personal Blog | My Software Company - Loop Foundry | My Github Page


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 6:06 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
It's plain flamebait. Ignore it. (*collects james' popcorn*)

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Asking further directions
PostPosted: Tue May 27, 2008 7:17 am 
Offline
Member
Member

Joined: Sat May 24, 2008 12:41 pm
Posts: 41
Location: La Plata, Argentina
svdmeer wrote:
indiocolifa wrote:
I successfully wrote a FAT12 boot sector on a disk and i'm writing the disk reading routines now. Since I'm new on this i would like to see some opinions on the route of my first toy OS:

1) What do you think it's easier? Going 16-bit RM or 32-bit PM? If going to PM32 want to create some form of 'Protected Mode DOS' where all code runs in ring 0. Sure, if all code runs in Ring 0 what is the benefit of PM at all? Well, no 1MB limit and segment mess, easier to code I think.


16-bit RM is much easier because you have full access to the BIOS and you memory management is very simple.
32-bit PM requires direct access to the hardware with everythinkg you do and memory management is more complicated, aspecially when you use paging.

Making a kind of DOS? The design of DOS sucks, it's historic, it doesn't mike sense anymore imo. Think about something new.

Quote:
3) And this is bizarre, what about creating some 16-bit Real Mode multitasking OS, trying to remain into the limitations of the 8086/88 programming model? This sounds like a good programming project.

Thank you very much.


Doesn't sound good to me. 16-bit realmode is a pre-historic thing. I think it's crazy x86 processors still have it. Serious OS-projects on ordinary hardware are 32-bit or 64-bit, not using any segmented memory and using paging.


Haha! :P

Yes, I know that 8086 segment addressing is incredibly painful to program for, that DOS was a very limited kind of "operating system" (sometimes I think if it deserves to call it "OS" ) but I want to start from something, I am not saying that my intention is to create a DOS clone, altough yes, it will run without protection (in Unreal mode, that's it) and be able to call BIOS, talk directly to hardware, etc.

I've finished writing in FASM the first stage of the boot loader, now with A20/Unreal mode/proper FAT12 kernel loading from diskette (this is to test things early).

So what I'm doing is: enabling A20, unreal mode, loading kernel at 0x10000000.

A question: it's possible to use ELF executables on Unreal mode? I know that's still real mode so I don't know the details of ELF to see if it's possible. Also I wonder if GCC can generate suitable executables for non-protected mode 32-bit binaries.

THank you very much.-


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: belliash, Bing [Bot] and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group