Page 1 of 2

The content of a basic 16 bit real mode opreating system

Posted: Mon Feb 22, 2016 4:45 am
by newbi
hello everyone, i'm a kind of newbi, but I set myself a target,
writing an opreating system in 16 bit real mode, i've come pretty far (for me at least).
my current opreating system gives the user writes an input (command) and by a specific input loads from the floppy image into virutal memory.
but i was asking myself, what more my os needs? currently the bios loads the kernel witch loads the keyboard handler program that maps the input and return the kernel what program should be loaded, what should i add? what more a 16 bit real mode os needs?
thanks in advance.

Re: The content of a basic 16 bit real mode opreating system

Posted: Mon Feb 22, 2016 6:07 am
by Brendan
Hi,
newbi wrote:but i was asking myself, what more my os needs?
To start with, it needs storage device drivers that aren't crippled pieces of trash (e.g. capable of transferring data to/from disk drives using DMA without completely freezing the entire computer). The next thing would be disk caches to avoid extremely expensive disk IO. The part after that will become obvious as soon as you've got usable drivers and usable caching (when you realise bare minimum functionality doesn't fit in < 640 KiB of RAM). ;)


Cheers,

Brendan

Re: The content of a basic 16 bit real mode opreating system

Posted: Mon Feb 22, 2016 8:41 am
by mallard
You'll probably need a bit more hardware support; hard drives, the mouse, possibly graphics hardware.

Apart from that, what do you want to do with your OS? If you look at the kinds of things that have been done in 16-bit real-mode in the past, you'll find that pretty much anything is possible; multitasking, GUIs, networking, plenty of "advanced" applications; databases, office software, even a couple of basic web browsers.

The big advantage of real-mode is that you have direct access to the BIOS and can use it as it was originally intended (to be a sort of "hardware abstraction layer" for the OS), greatly reducing the amount of time/effort needed for hardware support.

The disadvantages include the lack of memory, lack of protection and a lack of good tools/compilers.

A good implementation of "swapping" could help reduce memory pressure; if you make it possible to swap to/from disk or extended memory where available (you don't even need to write any protected-mode code yourself to achieve this; BIOS INT 15h, function 87h can be used).

The lack of protection means that you can't stop programs from accessing data/hardware that they shouldn't, either deliberately/maliciously or accidentally. Since it's your OS, you shouldn't have to worry about malicious applications, but accidental memory corruption can happen easily. Still, reasonable levels of stability were achieved back when real-mode was the most commonly used (and often only) mode in the 1980s...

The Open Watcom toolchain is probably the most "modern" toolchain with decent real-mode support, but it is aimed at producing executables for DOS, so you'll probably have to stay clear of its standard library.

Re: The content of a basic 16 bit real mode opreating system

Posted: Mon Feb 22, 2016 8:37 pm
by ~
newbi wrote:hello everyone, i'm a kind of newbi, but I set myself a target,
writing an opreating system in 16 bit real mode, i've come pretty far (for me at least).
my current opreating system gives the user writes an input (command) and by a specific input loads from the floppy image into virutal memory.
but i was asking myself, what more my os needs? currently the bios loads the kernel witch loads the keyboard handler program that maps the input and return the kernel what program should be loaded, what should i add? what more a 16 bit real mode os needs?
thanks in advance.
I have been writing a kernel. It boots from a FAT12 boot sector and enables Protected Mode. It uses Unreal Mode to load the kernel image. You can clearly see how it was created and you could modify the boot code to load a Real Mode image:

Implementing an Operating System (The LowEST Kernel)


One of the things that would prove to be more useful to you is to implement a few BIOS functions at a time so you can use the functions you employ from Real Mode (presumably a few) into Protected and Long Mode.

The most problematic functions to implement would be the ones dealing with graphics, but you could find a way to debug/single-step/emulate/dump the classic and PCI/etc., registers of the graphics card and use that data and sequences to make a simple implementation for your kernel.

You could also call the Memory Mapping and other BIOS functions that return data to dump that data (such as I/O port, memory addresses, signatures...) and getting to build functions specific to your motherboard in your 32 or 64-bit kernel and implement functions there that return that data again in the same structured way or in an equivalent way (and the same would go about saving the full state of the machine and the peripherals before leaving Real Mode).

Re: The content of a basic 16 bit real mode opreating system

Posted: Mon Feb 22, 2016 9:29 pm
by Brendan
Hi,
mallard wrote:The big advantage of real-mode is that you have direct access to the BIOS and can use it as it was originally intended (to be a sort of "hardware abstraction layer" for the OS), greatly reducing the amount of time/effort needed for hardware support.
That's mostly a myth. It allows you to use BIOS functions for a few things that you haven't implemented properly yet (which is a minor temporary advantage), but doesn't avoid the need to implement things properly (eventually).

More specifically; the disk IO the BIOS provides is unusable (massive performance problems), the keyboard support is completely broken (no IPC/events system, no keyboard layouts), the mouse interface is worthless (often it isn't supported/doesn't work, and when it does work there's no IPC/events system), the video support is also barely usable (no GPU or 3D acceleration, no support for multiple video cards/monitors, etc), the support for serial ports is unusable (you will lose data), there is no support for networking devices at all, there is no support for modern sound at all, there is no support for device insertion/removal (so support for things like USB devices is a joke), etc.

What it does do is make it extremely difficult (and/or impossible) to do anything properly; partly because the BIOS expects hardware to remain in a certain default state (preventing you from doing anything useful with IO APICs, MSI, PCI configuration space, etc); and partly because of physical address space restrictions (e.g. not being able to touch anything outside the first 640 KiB of the physical address space, including things like APICs and HPET, including all memory mapped IO areas for PCI devices, including the BIOSs own ACPI and SMBIOS tables, etc).

Basically; people think it makes things easier, but it actually makes everything much much harder. Even for a single-tasking OS that runs in real mode; it's easier to forget about the BIOS (beyond initial boot code) just so you're able to do something (anything) right.


Cheers,

Brendan

Re: The content of a basic 16 bit real mode opreating system

Posted: Tue Feb 23, 2016 3:05 am
by mallard
Brendan wrote:That's mostly a myth.
No it is not. The BIOS was absolutely designed to be used as a "HAL", that's exactly how DOS, CP/M-86 and UCSD P-System (the original 3 IBM PC OSs) used it. Unfortunately, after IBM lost control of the PC platform in ~1987, nobody updated the BIOS for newer hardware.

IBM's PS/2 systems (the commercial failure that they were) had an "ABIOS" which was designed to be used as a "HAL" by OS/2. It was callable from protected mode and multitasking-friendly; showing the direction the BIOS would have developed had IBM remained in control. It was absolutely intended to be a "HAL", just like the ROM/firmware in other 1980s computer designs; most notably the Macintosh's "Toolbox ROM".

If someone's designing an OS for 16-bit real-mode, there is absolutely zero point in talking about 3D acceleration, USB, APIC, HPET, etc. Of course they're not easily usable. Any real-mode OS in 2016 is a hobby project; a "toy", it's not going to achieve mass-market appeal. That is absolutely fine; sometimes is fun just to see what you can do with limited resources. It's the same reason that hobbyists still make games for the NES or Atari 2600.

As proven by multitudes of software written for DOS in the 80s/90s, the BIOS is absolutely usable as long as you stay within its limitations.

You seriously need to stop with this attitude of "you should only built an OS if you're after world domination". You may have delusions of becoming the next Microsoft, but most people are far more realistic. Disparaging other people's ideas and goals simply because you have different ones is counter-productive and fairly anti-social.

Re: The content of a basic 16 bit real mode opreating system

Posted: Tue Feb 23, 2016 6:01 am
by newbi
mallard wrote:
Brendan wrote:That's mostly a myth.
No it is not. The BIOS was absolutely designed to be used as a "HAL", that's exactly how DOS, CP/M-86 and UCSD P-System (the original 3 IBM PC OSs) used it. Unfortunately, after IBM lost control of the PC platform in ~1987, nobody updated the BIOS for newer hardware.

IBM's PS/2 systems (the commercial failure that they were) had an "ABIOS" which was designed to be used as a "HAL" by OS/2. It was callable from protected mode and multitasking-friendly; showing the direction the BIOS would have developed had IBM remained in control. It was absolutely intended to be a "HAL", just like the ROM/firmware in other 1980s computer designs; most notably the Macintosh's "Toolbox ROM".

If someone's designing an OS for 16-bit real-mode, there is absolutely zero point in talking about 3D acceleration, USB, APIC, HPET, etc. Of course they're not easily usable. Any real-mode OS in 2016 is a hobby project; a "toy", it's not going to achieve mass-market appeal. That is absolutely fine; sometimes is fun just to see what you can do with limited resources. It's the same reason that hobbyists still make games for the NES or Atari 2600.

As proven by multitudes of software written for DOS in the 80s/90s, the BIOS is absolutely usable as long as you stay within its limitations.

You seriously need to stop with this attitude of "you should only built an OS if you're after world domination". You may have delusions of becoming the next Microsoft, but most people are far more realistic. Disparaging other people's ideas and goals simply because you have different ones is counter-productive and fairly anti-social.
hello and thanks for everything.
this is indeed a hobby, more of a project for school, nothing major or too diffuclt, just for fun and simple used, i'll tell you what currently my os is doing and what im looking forword to do and if u can help me that'd be great,
currently my bootloader loads the kernel wich loads the next sector containing a keyboardhandler program wich recive input from user, acting by that input it loads sector (every sector is a diffrent program), and pass control to it.
I want to build a file editior, but so far everysingle file i wrote wich meant to be used on the use (exclude the include files) is compiled to bin files and written to a floppy, but how can i write a file txt wich the user can loads and write into? thanks.

Re: The content of a basic 16 bit real mode opreating system

Posted: Tue Feb 23, 2016 6:16 am
by Brendan
Hi,
mallard wrote:
Brendan wrote:That's mostly a myth.
No it is not. The BIOS was absolutely designed to be used as a "HAL", that's exactly how DOS, CP/M-86 and UCSD P-System (the original 3 IBM PC OSs) used it. Unfortunately, after IBM lost control of the PC platform in ~1987, nobody updated the BIOS for newer hardware.
Yes, it is a myth. Maybe 25+ years ago (when hardware was much much simpler, and what people expected from an OS and software in general was much much simpler) it was true, but it's not true now and hasn't been for a very long time.
mallard wrote:You seriously need to stop with this attitude of "you should only built an OS if you're after world domination". You may have delusions of becoming the next Microsoft, but most people are far more realistic. Disparaging other people's ideas and goals simply because you have different ones is counter-productive and fairly anti-social.
It has nothing to do with world domination.

It's natural for (some) beginners to see things like enabling protected mode and get a little confused/scared, and (sadly) it's also a little natural for them to assume real mode is an easy alternative without realising it makes it impossible to learn anything useful (which is the most common goal) and makes it impossible to do any hobby/toy system that isn't a hideously pointless joke (which is the second most common goal).

These people just need a little "nudge" to help them overcome their initial fears and enable them to do achieve what they actually want to achieve.

People like you who actively encourage beginners to give in to their fears and stay with real mode are maliciously incompetent. You are not interested in helping beginners overcome their initial fears, or improving beginner's knowledge, or their confidence, or making it easier for them to achieve their goals (whatever those goals actually are). It's like your are holding their head under water while they're trying to learn how to swim.


Cheers,

Brendan

Re: The content of a basic 16 bit real mode opreating system

Posted: Tue Feb 23, 2016 6:22 am
by ~
newbi wrote:hello and thanks for everything.
this is indeed a hobby, more of a project for school, nothing major or too diffuclt, just for fun and simple used, i'll tell you what currently my os is doing and what im looking forword to do and if u can help me that'd be great,
currently my bootloader loads the kernel wich loads the next sector containing a keyboardhandler program wich recive input from user, acting by that input it loads sector (every sector is a diffrent program), and pass control to it.
I want to build a file editior, but so far everysingle file i wrote wich meant to be used on the use (exclude the include files) is compiled to bin files and written to a floppy, but how can i write a file txt wich the user can loads and write into? thanks.
You should learn to use a filesystem like FAT12 or FAT32 since it will allow you to load programs and data easily from other OS like DOS, Windows or Linux. It needs some effort being able to do that, so the first thing would be to get a clean code to access the floppy drive or a hard disk.

I think that you could only receive help if you put the code of your project so we can compile it and guide you at every single step. In that way we can contribute information that you can add immediately to your source code. It also helps others practice, learn and improve the documentation.

That's what I and virtually everyone here have done and it will most likely save you a decade of effort and will make you understand more things in months or a year, so you get to understand all the basics immediately.

Re: The content of a basic 16 bit real mode opreating system

Posted: Tue Feb 23, 2016 7:32 am
by Brendan
Hi,
~ wrote:
newbi wrote:hello and thanks for everything.
this is indeed a hobby, more of a project for school, nothing major or too diffuclt, just for fun and simple used, i'll tell you what currently my os is doing and what im looking forword to do and if u can help me that'd be great,
currently my bootloader loads the kernel wich loads the next sector containing a keyboardhandler program wich recive input from user, acting by that input it loads sector (every sector is a diffrent program), and pass control to it.
I want to build a file editior, but so far everysingle file i wrote wich meant to be used on the use (exclude the include files) is compiled to bin files and written to a floppy, but how can i write a file txt wich the user can loads and write into? thanks.
You should learn to use a filesystem like FAT12 or FAT32 since it will allow you to load programs and data easily from other OS like DOS, Windows or Linux. It needs some effort being able to do that, so the first thing would be to get a clean code to access the floppy drive or a hard disk.

I think that you could only receive help if you put the code of your project so we can compile it and guide you at every single step. In that way we can contribute information that you can add immediately to your source code. It also helps others practice, learn and improve the documentation.

That's what I and virtually everyone here have done and it will most likely save you a decade of effort and will make you understand more things in months or a year, so you get to understand all the basics immediately.
This is a nice idea, but I'm afraid it's not that simple.

I strongly suspect that the reason newbi's plans are so unambitious is that newbi has very little experience with programming (in any language); and that the code will be a "Frankenstien" style combination of pieces cut & pasted from multiple tutorials. In that case; the best thing we can do for newbi is to encourage them to get more experience with programming (e.g. writing applications) and come back when they have more knowledge (and the confidence that gaining knowledge would bring). Otherwise it'll be an extremely slow/painful process (trying to learn programming, and computer architecture, and OS development, and deprecated APIs, all at the same time).


Cheers,

Brendan

Re: The content of a basic 16 bit real mode opreating system

Posted: Tue Feb 23, 2016 8:37 am
by ~
Brendan wrote:Hi,
~ wrote:
newbi wrote:hello and thanks for everything.
this is indeed a hobby, more of a project for school, nothing major or too diffuclt, just for fun and simple used, i'll tell you what currently my os is doing and what im looking forword to do and if u can help me that'd be great,
currently my bootloader loads the kernel wich loads the next sector containing a keyboardhandler program wich recive input from user, acting by that input it loads sector (every sector is a diffrent program), and pass control to it.
I want to build a file editior, but so far everysingle file i wrote wich meant to be used on the use (exclude the include files) is compiled to bin files and written to a floppy, but how can i write a file txt wich the user can loads and write into? thanks.
You should learn to use a filesystem like FAT12 or FAT32 since it will allow you to load programs and data easily from other OS like DOS, Windows or Linux. It needs some effort being able to do that, so the first thing would be to get a clean code to access the floppy drive or a hard disk.

I think that you could only receive help if you put the code of your project so we can compile it and guide you at every single step. In that way we can contribute information that you can add immediately to your source code. It also helps others practice, learn and improve the documentation.

That's what I and virtually everyone here have done and it will most likely save you a decade of effort and will make you understand more things in months or a year, so you get to understand all the basics immediately.
This is a nice idea, but I'm afraid it's not that simple.

I strongly suspect that the reason newbi's plans are so unambitious is that newbi has very little experience with programming (in any language); and that the code will be a "Frankenstien" style combination of pieces cut & pasted from multiple tutorials. In that case; the best thing we can do for newbi is to encourage them to get more experience with programming (e.g. writing applications) and come back when they have more knowledge (and the confidence that gaining knowledge would bring). Otherwise it'll be an extremely slow/painful process (trying to learn programming, and computer architecture, and OS development, and deprecated APIs, all at the same time).


Cheers,

Brendan
It's a difficult process but it can be abbreviated to the extent that those problems have clearly been described along with fully-runnable snippets to run from a custom operating system for tests, or from DOS, or with special low-level development applications and drivers for Windows/Linux.

It seems to me that at this point the beginners can become a key to follow up the needs of a newcomer in a clear way and to get to explain more advanced topics but make things trivial from the very basics no matter how difficult or complex they are, and now that I have a program to record any changes as if the developer was typing the operating system code from the beginning in front of everyone who sees that text/code recording, any code that is produced will become extremely valuable and understandable, and even if it looks very ugly, incomplete and inefficient in the beginning, it is a necessary stage to improve the level of the people who reads the documentation and the documentation itself more practically and immediately.

Re: The content of a basic 16 bit real mode opreating system

Posted: Tue Feb 23, 2016 10:02 am
by mallard
Brendan wrote: People like you who actively encourage beginners to give in to their fears and stay with real mode are maliciously incompetent. You are not interested in helping beginners overcome their initial fears, or improving beginner's knowledge, or their confidence, or making it easier for them to achieve their goals (whatever those goals actually are). It's like your are holding their head under water while they're trying to learn how to swim.
No. You're assuming that the only reason anyone would want to build a real-mode OS is doing so because they're "afraid" of protected mode. That's not true at all. You don't know anyone's motivations except your own. "newbi" said that they wanted to create a real-mode OS. Any fear or lack of confidence is something you've made up, based on your own prejudices. Just like with the game hobbyists I mentioned before, it can be fun to create software for obsolete computers. People can have different goals to you for reasons entirely unrelated to fears or lack of confidence. Stop projecting.

I own a couple of HP Palmtop PCs; 80186 (so real-mode only) systems with CGA graphics, DOS in ROM, persistent RAM disk and PCMCIA for storage (all storage is effectively BIOS-only, the hardware interfaces are not well understood/documented), pocket-sized and run for a few weeks on a pair of AA batteries. I have a vague aspiration to build an alternative OS for them at some point. The fact that it would have to run in real mode and use the BIOS for storage access has zero to do with any fear or lack of confidence, it's the limitations of the target platform! How do you know that "newbi" doesn't have a similarly ancient/unusual piece of hardware in mind for their OS?

Re: The content of a basic 16 bit real mode opreating system

Posted: Tue Feb 23, 2016 11:20 am
by Brendan
Hi,
mallard wrote:
Brendan wrote:People like you who actively encourage beginners to give in to their fears and stay with real mode are maliciously incompetent. You are not interested in helping beginners overcome their initial fears, or improving beginner's knowledge, or their confidence, or making it easier for them to achieve their goals (whatever those goals actually are). It's like your are holding their head under water while they're trying to learn how to swim.
No. You're assuming that the only reason anyone would want to build a real-mode OS is doing so because they're "afraid" of protected mode. That's not true at all. You don't know anyone's motivations except your own. "newbi" said that they wanted to create a real-mode OS. Any fear or lack of confidence is something you've made up, based on your own prejudices. Just like with the game hobbyists I mentioned before, it can be fun to create software for obsolete computers. People can have different goals to you for reasons entirely unrelated to fears or lack of confidence. Stop projecting.

I own a couple of HP Palmtop PCs; 80186 (so real-mode only) systems with CGA graphics, DOS in ROM, persistent RAM disk and PCMCIA for storage (all storage is effectively BIOS-only, the hardware interfaces are not well understood/documented), pocket-sized and run for a few weeks on a pair of AA batteries. I have a vague aspiration to build an alternative OS for them at some point. The fact that it would have to run in real mode and use the BIOS for storage access has zero to do with any fear or lack of confidence, it's the limitations of the target platform! How do you know that "newbi" doesn't have a similarly ancient/unusual piece of hardware in mind for their OS?
Have a look at newbi's previous posts and see if you can figure out why newbi is aiming for real mode. I can virtually guarantee it has nothing at all to do with wanting to support museum pieces, and everything to do with lack of knowledge/experience (possibly combined with worthless "anti-helpers" like you failing to put newbi on the right track). Your attempt to suggest otherwise is a gross misrepresentation.


Cheers,

Brendan

Re: The content of a basic 16 bit real mode opreating system

Posted: Sat Feb 27, 2016 8:25 am
by newbi
mallard wrote:
Brendan wrote: People like you who actively encourage beginners to give in to their fears and stay with real mode are maliciously incompetent. You are not interested in helping beginners overcome their initial fears, or improving beginner's knowledge, or their confidence, or making it easier for them to achieve their goals (whatever those goals actually are). It's like your are holding their head under water while they're trying to learn how to swim.
No. You're assuming that the only reason anyone would want to build a real-mode OS is doing so because they're "afraid" of protected mode. That's not true at all. You don't know anyone's motivations except your own. "newbi" said that they wanted to create a real-mode OS. Any fear or lack of confidence is something you've made up, based on your own prejudices. Just like with the game hobbyists I mentioned before, it can be fun to create software for obsolete computers. People can have different goals to you for reasons entirely unrelated to fears or lack of confidence. Stop projecting.

I own a couple of HP Palmtop PCs; 80186 (so real-mode only) systems with CGA graphics, DOS in ROM, persistent RAM disk and PCMCIA for storage (all storage is effectively BIOS-only, the hardware interfaces are not well understood/documented), pocket-sized and run for a few weeks on a pair of AA batteries. I have a vague aspiration to build an alternative OS for them at some point. The fact that it would have to run in real mode and use the BIOS for storage access has zero to do with any fear or lack of confidence, it's the limitations of the target platform! How do you know that "newbi" doesn't have a similarly ancient/unusual piece of hardware in mind for their OS?
I do lack experiance, but that is not the reason I'm look to build a 16 bit realmode machine, the actuall easy way is a protected mode 32 bits for a begginer to start with, putting aside the assembly level, a protected mode have much much more supports via forums and information on the internet, from articeles to books, every single one I found was started from basic 16 bits but every time ended with protected mode and a high language programing of some kind, not looking for some out of the mind blowing os, just some simple fun stuff.
Brendan wrote:Hi,
mallard wrote:
Brendan wrote:People like you who actively encourage beginners to give in to their fears and stay with real mode are maliciously incompetent. You are not interested in helping beginners overcome their initial fears, or improving beginner's knowledge, or their confidence, or making it easier for them to achieve their goals (whatever those goals actually are). It's like your are holding their head under water while they're trying to learn how to swim.
No. You're assuming that the only reason anyone would want to build a real-mode OS is doing so because they're "afraid" of protected mode. That's not true at all. You don't know anyone's motivations except your own. "newbi" said that they wanted to create a real-mode OS. Any fear or lack of confidence is something you've made up, based on your own prejudices. Just like with the game hobbyists I mentioned before, it can be fun to create software for obsolete computers. People can have different goals to you for reasons entirely unrelated to fears or lack of confidence. Stop projecting.

I own a couple of HP Palmtop PCs; 80186 (so real-mode only) systems with CGA graphics, DOS in ROM, persistent RAM disk and PCMCIA for storage (all storage is effectively BIOS-only, the hardware interfaces are not well understood/documented), pocket-sized and run for a few weeks on a pair of AA batteries. I have a vague aspiration to build an alternative OS for them at some point. The fact that it would have to run in real mode and use the BIOS for storage access has zero to do with any fear or lack of confidence, it's the limitations of the target platform! How do you know that "newbi" doesn't have a similarly ancient/unusual piece of hardware in mind for their OS?
Have a look at newbi's previous posts and see if you can figure out why newbi is aiming for real mode. I can virtually guarantee it has nothing at all to do with wanting to support museum pieces, and everything to do with lack of knowledge/experience (possibly combined with worthless "anti-helpers" like you failing to put newbi on the right track). Your attempt to suggest otherwise is a gross misrepresentation.


Cheers,

Brendan
hello Brendan, I sure do appreciate your experience and knowledge, I am by 100% sure you know better then i do almost everything im trying to do, but you don’t understand why I am doing it, not short cut, no copy paste code, 100% my code, looking for every bios interup i used and a method to use it and my own algorithm of using it, I dont look currently for a "usefull os" or whatever you are trying to pass on to people, please avoid replying to my threads, thank you anyway for everything, you just dont seem to get my intentions.

Re: The content of a basic 16 bit real mode opreating system

Posted: Sat Feb 27, 2016 9:36 am
by iansjack
I dont look currently for a "usefull os" or whatever you are trying to pass on to people, please avoid replying to my threads, thank you anyway for everything, you just dont seem to get my intentions.
If you don't want help then don't ask for it.

If it's your OS and you are doing it just for fun then you decide what it needs next. Don't ask people to make the decision for you (and then complain when they do).