I have successfully conquered the basics of protected mode, but I have realised that there are many other things to do. I have to:
Understand paging
Understand task-switching
Understand DMA (is it needed?) and the A20 thingy??
Make an SVGA driver
Make a hard disk driver and FAT32 filesystem
Make keyboard and mouse drivers
I am not looking for examples of how to do these things. Rather I am asking for advice on whether this is the right approach, any useful sites you might know and maybe a broad approach of how to actually do these things.
Thanks everybody.
(By the way, my philosophy for my OS is for it to be fully compatible with Windows; no reformatting of hard disks or anything like that.)
Some links that might help:
http://www.osdever.net
http://www.mega-tokyo.com/forum/?board=1
http://www.nondot.org/sabre/os/articles
http://cdsmith.twu.net/professional/osdesign.html
I think you need to get past A20 first. No big problem with that - all you need to do is find some available A20 codes online and throw it in your os. :toothy I think the next most important thing to do is set up your idt and gdt and change your irq.
The source code for a complete 32-bit, message-based, multitasking, real-time operating system is available for download here:
http://www.sensorypublishing.com/mmurtl.html
The source includes a C compiler and an assembler. The book, which is not free, includes an Architecture and General Theory section of ~100 pages, and a specific details section of ~200 pages.
Hi,
Keyboard drivers are easy enough if you understand it. I am stuck at making a memory manager for my OS :red . Get my OS at http://www.tomasm.tk/ . It has Floppy disk driver with FAT12, keyboard, etc. in protected mode wiyth a basic commandline
Thomas Antony :U
Quote from: AeroASM on April 16, 2005, 01:26:16 PM
(By the way, my philosophy for my OS is for it to be fully compatible with Windows; no reformatting of hard disks or anything like that.)
If this only means a compatible (FAT) file system, that's probably doable. However, making an OS that can run any commercial Windows application is too ambitious.
I overestimated when I said "fully compatible". Basically the reason is that I use the same computer for my schoolwork, and don't want to get it screwed up, and so by compatible I meant I can shutdown, boot to my own OS, shutdown, and boot to Windows without any hiccups.
You can make sure that none of your data on your hdd gets destroyed by not touching data on your hdd at all. Just load everything from the floppy and don't touch the hdd at all.
Quote from: AeroASM on April 20, 2005, 06:33:55 PM
I overestimated when I said "fully compatible". Basically the reason is that I use the same computer for my schoolwork, and don't want to get it screwed up, and so by compatible I meant I can shutdown, boot to my own OS, shutdown, and boot to Windows without any hiccups.
Yeah,
I was about to say that. Make a FAT12 compatible bootsector to load the files from the floppy. Maybe make a secondary loader to load the kernel and set up everything else. So you don't touch the HDD. When you want to boot, boot from the floppy. Also its bad to rebott to test every small change you make. Instead run it in an emulator like Bochs. ( http://bochs.sourceforge.net/ )
Thomas :U
I have no floppy drive. (or floppy disks)
What about a USB thumbdrive or something?
Wow, all the young people seem to be wanting to make OS's all of a sudden. I'd jump onto the bandwagon, but I'm just not that ambitous. Good luck to y'all, and may you one day supplant Linux. :U
I have no usb stick either. Bieb, would you consider teaming up with me?
Actually, I think I will. I'm completely at a loss for what to do as my next project, and working on an OS should be a great learning experience. Email me with the details, please. Oh, and you should probably go for something like VM Ware for testing it. I'm considering buying it myself.
Hi,
I personally use Bochs for OSDev. YOu need to learn how to use its scripts and then its really easy. It also has a good debugger. I recommend checking out http://www.osdever.net/ , http://www.mega-tokyo.com/ and google. The Osdeve.net site had a forum but its down now because some a**holes hacked i sometime ago. They are not putting it up for sometime.
Thomas :U
I got Bochs, but I do not think I will use it. Is there no simple way to just load a flat .bin file into memory and execute it?
Yes there is. Rename the file to .COM and put an ORG 100h instead of any other ORG instruction in the source. And go into DOS mode (not DOS shell, select Restart in MSDOS mode in Shutdown menu). Go to whatever directory you have the program and run it. I think making a Bochs image file and running it is much easier than this. Making an image is very simple. If you use NASM put the following in a file (empty.asm, dummy.asm bullsh*t.asm anything..)
times 1474560-(your_bin_file_size) db 0
Now assemble the file to get dummy.bin
Now do the following DOS command
copy /B your_bin_file.bin+dummy.bin a.img
There you have your image file. You can put all the assembling and other things into a batch file to make it easy
Thomas
For OS coding, I use fasm which can output binary. I use winimage to create the floppy disk image and use vmware/virtual pc to test it.
I have the code for set flat real mode, but unfortunately this computer cannot open a .zip file. Maybe you can get use of it. Or if you can, please check my post titled "Courious about Opcode?".
AeroASM,
http://www.emu8086.com/ is a nice Visual Microprocessor Emulator. It also has its own Assembler as well as sample code for creating a tiny OS. When you load the source code you can copy it to a virtual floppy (memory) and test it there. It is a nifty tool as it can emulate a lot of stuff.
Paul
I have got that but it is no use for Protected Mode
Hi roticv,
Isn't it a pain in the a** if you have to use WinImage every time you have to check out a small change you made to the prog. I use the following batch file for tesing my FAT12 OS. It copies the files and copies some 100k into an image file so that it contains the FAT structures, the file data etc. Then I add a dummy file at the end.
@echo off
nasm -fbin -o boot.com boot.asm
if errorlevel 1 goto exit
nasm -fbin -o oskernel.com oskernel.asm
if errorlevel 1 goto exit
nasm -fbin -o dummy.bin dummy.asm
copy logo.txt a:
debug boot.com < debugops.ini
copy oskernel.com a:
:partcopy -f0 0 3E800 os.bin
partcopy -f0 0 19000 os.bin
copy /b os.bin+dummy.bin a.img
\bochs\bochs -q
:\bochs\bochsdbg -q
del dummy.bin
del os.bin
:exit
debugops.ini contians:
w 100 0 0 1
q
So I can test my OS simply by running this batch file.
Thomas :U
By the way, there is a way that you can "delete" a step in your work ;) or a workaround..
Files:
1) boot.asm
1) kernel.asm
2) img.asm
img.asm:
incbin "boot.bin"
incbin "kernel.bin"
;%assign addition FSIZE
;%error Size of boot.bin+kernel.bin = s
times 1474560- (FSIZE) db 0
compile it with:
nasmw -fbin -oimg.img -DFSIZE=15 img.asm
Sure, before you should know the size of the kernel.bin and boot.bin, and sure you can use -DFSIZE 15+30 if you dont whant to make the adition ;), yiu can uncomment the lines if you whant to check them ;).
-------------------------------------------
[FIX]
Ops, I was missing a operator in a previous try, now I have remembered another one, then it can be reduced more ;)
img.asm:
incbin "boot.bin" incbin "kernel.bin" times 1474560- ($-$$) db 0
|
or
start_here: incbin "boot.bin" incbin "kernel.bin" end_here: times 1474560- (end_here-start_here) db 0
|
compile it with:
nasmw -fbin -oimg.img img.asm
And dont need to add :P, I was failing because I was only using times "1474560- $ db 0", that dosent work ;).
[/FIX]
I do another sugestion.. because $$ signal the start of the segment then is the same than the second one way...
Hi,
Should have got this before. I think I can still use it by 'incbinning' the FAT data read from the disk.
Thomas :U
AeroASM: You do not need a PHYSICAL floppy drive, you can emulate it by using VMware WorkStation (I use 5.0 for my boot tests) ;))