Page 1 of 1
frantOS - my first x86 bare metal project
Posted: Tue Jul 21, 2020 8:35 am
by frantog
A simple bare metal project.
frantOS display two bitmap images(with VGA palette), one as a background and the other one as a sprite sheet(animating it).
It contains some simple image manipulation functions, such as draw with subtract or draw by region.
Reading the keyboard by interrupt, you can make some graphical changes to the displaying video(drawing a square and changing its color)and save the video memory as a bmp on the primary ATA.
frantOS works in protected mode, it's compiled in 32bit, and was tested on a real 32bit machine. It implements interrupts in assembly and contain a little and simple ATA write driver. Hope you like it
Youtube video
https://www.youtube.com/watch?v=cCilnmk6WnE
Github source:
https://github.com/frangr/frantOS
Re: frantOS - my first x86 bare metal project
Posted: Wed Jul 22, 2020 5:31 am
by nexos
Looks great! I will have to try it out.
Re: frantOS - my first x86 bare metal project
Posted: Wed Jul 22, 2020 5:44 am
by PeterX
Looks great. Seems more like a game engine than an OS. But since I like OSs and game engines both, I don't care!
One could write a game for your OS. Did I mention that it looks great?
EDIT: I read your Readme and it says it's not a OS. Shouldn't you rename it then? Anyway, it's a cool bare metal program. I think I will put a similar game engine on my OS TODO list.
Was it hard to edit the walking animation of the sprite?
Greetings
Peter
Re: frantOS - my first x86 bare metal project
Posted: Wed Jul 22, 2020 4:17 pm
by frantog
nexos wrote:Looks great! I will have to try it out.
Glad you like it!
PeterX wrote:Looks great. Seems more like a game engine than an OS. But since I like OSs and game engines both, I don't care!
One could write a game for your OS. Did I mention that it looks great?
EDIT: I read your Readme and it says it's not a OS. Shouldn't you rename it then? Anyway, it's a cool bare metal program. I think I will put a similar game engine on my OS TODO list.
Was it hard to edit the walking animation of the sprite?
Greetings
Peter
Thank you Peter!
Yeah, I should rename it. I called my project like that because it sounded good with my nickname("franto")... any suggestion is accepted
The hard part was parsing the bitmap. Not the header, but parsing the pixel map. For some reason the bitmap file start storing the pixels backwards(first pixel in the map is the last one in the image). So you need to parse the data as "pixel[width*height]--". But when an image is backward, it become mirrored too. So you have to parse data as '(pixel[width*height] - width)++' and then subtract width*2 when it reach the end. This is not so difficult, but it become so when you have to select an image by region. Go to see function "draw_bmp_region" in the main.cpp to see the struggle lol
Anyway, I had some troubles in writing the ATA write code. when called more than once(in things like cycles or just calling it more than once), it would not write, or write gibberish. This lasted until I put a "cache flush" command in the driver (or at least this was my impression, I have to test if it's actually the cache flush that resolve the problem).
Code: Select all
void ATA_write(uint32_t LBA, uint8_t sec_n, uint16_t* data_buffer)
{
uint8_t bt = LBA >> 24 | 0xE0;
out(0x1F6, bt);
uint8_t delay = in(0x1F7);
delay = in(0x1F7);
delay = in(0x1F7);
delay = in(0x1F7);
out(0x1F2, sec_n); //number of sectors to write
out(0x1F3, LBA);
out(0x1F4, LBA >> 8);
out(0x1F5, LBA >> 16);
out(0x1F7, 0x30); //read with retry = 0x20, write with retry = 0x30
//clear_screen(3);
//servicing
while( (in(0x1F7) & 0x8) == 0 ) {}
for(int i=0; i<sec_n*256; i++)
outw(0x1F0, data_buffer[i]);
out(0x1F7, 0xE7); //cache flush
return;
}
This is not mentioned in the
ATA read/write sectors osdev wiki page. It should? Or I'm the only one to have encountered this problem? Let me know.
This is where I saw the cache flush code. Line 0302
(sorry for the long post, and sorry if there is some grammar error too, english is not my first language)
Re: frantOS - my first x86 bare metal project
Posted: Thu Jul 23, 2020 7:38 pm
by thewrongchristian
frantog wrote:
Anyway, I had some troubles in writing the ATA write code. when called more than once(in things like cycles or just calling it more than once), it would not write, or write gibberish. This lasted until I put a "cache flush" command in the driver (or at least this was my impression, I have to test if it's actually the cache flush that resolve the problem).
This is not mentioned in the
ATA read/write sectors osdev wiki page. It should? Or I'm the only one to have encountered this problem? Let me know.
This is where I saw the cache flush code. Line 0302
Cache flush gets mentioned in:
https://wiki.osdev.org/ATA_PIO_Mode#Cache_Flush
The various ATA pages are a bit hap-hazard, but I found the above one easiest to follow so far. My ATA driver is based largely on this page, but I found it hard going.
Re: frantOS - my first x86 bare metal project
Posted: Fri Jul 24, 2020 6:59 am
by PeterX
Here some name suggestions:
"frantoengine"
"frantogfx"
"frantostic"
Greetings
Peter
Re: frantOS - my first x86 bare metal project
Posted: Sat Jul 25, 2020 7:29 am
by ArgonAquila
I posted email to you so you can check it. This is my impression to you after my failure.
Re: frantOS - my first x86 bare metal project
Posted: Sat Jul 25, 2020 8:30 am
by bzt
ArgonAquila wrote:I posted email to you so you can check it. This is my impression to you after my failure.
Please mind your manners. You've made all the classic mistakes an OSdev-wannabe could make. There's nothing wrong with that if you are able to learn from those. Unlike you, the OP has already shown he can write code, has solid understanding of CPU modes and bare metal interfaces, and he did not asked others to write an OS for them.
Cheers,
bzt
Re: frantOS - my first x86 bare metal project
Posted: Sat Jul 25, 2020 9:34 am
by ArgonAquila
bzt wrote:ArgonAquila wrote:I posted email to you so you can check it. This is my impression to you after my failure.
Please mind your manners. You've made all the classic mistakes an OSdev-wannabe could make. There's nothing wrong with that if you are able to learn from those. Unlike you, the OP has already shown he can write code, has solid understanding of CPU modes and bare metal interfaces, and he did not asked others to write an OS for them.
Cheers,
bzt
I understand dude. I am 17 but learned how to not to be dickhead while making project.
I am such a dickhead that ashamed myself that I lost my OS project.
Re: frantOS - my first x86 bare metal project
Posted: Sat Jul 25, 2020 9:43 am
by ArgonAquila
bzt wrote:ArgonAquila wrote:I posted email to you so you can check it. This is my impression to you after my failure.
Please mind your manners. You've made all the classic mistakes an OSdev-wannabe could make. There's nothing wrong with that if you are able to learn from those. Unlike you, the OP has already shown he can write code, has solid understanding of CPU modes and bare metal interfaces, and he did not asked others to write an OS for them.
Cheers,
bzt
Also this is not classic mistake. I am the first guy who made this biggest mistake that no developer never forgives.
THE FIRST TIME IN PROGRAMMING COMMUNITY.