frantOS - my first x86 bare metal project

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
User avatar
frantog
Posts: 2
Joined: Mon Jun 29, 2020 1:35 pm

frantOS - my first x86 bare metal project

Post 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
nexos
Member
Member
Posts: 1078
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: frantOS - my first x86 bare metal project

Post by nexos »

Looks great! I will have to try it out.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: frantOS - my first x86 bare metal project

Post 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
User avatar
frantog
Posts: 2
Joined: Mon Jun 29, 2020 1:35 pm

Re: frantOS - my first x86 bare metal project

Post by frantog »

nexos wrote:Looks great! I will have to try it out.
Glad you like it! :mrgreen:
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)
thewrongchristian
Member
Member
Posts: 425
Joined: Tue Apr 03, 2018 2:44 am

Re: frantOS - my first x86 bare metal project

Post 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.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: frantOS - my first x86 bare metal project

Post by PeterX »

Here some name suggestions:
"frantoengine"
"frantogfx"
"frantostic"

Greetings
Peter
ArgonAquila
Posts: 15
Joined: Fri Jul 17, 2020 12:43 pm
Libera.chat IRC: argonaquila
Location: Paraguay
Contact:

Re: frantOS - my first x86 bare metal project

Post by ArgonAquila »

I posted email to you so you can check it. This is my impression to you after my failure.
Prendre soin de sa sante www.viagrasansordonnancefr.com pharmacie de Paris
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: frantOS - my first x86 bare metal project

Post 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
ArgonAquila
Posts: 15
Joined: Fri Jul 17, 2020 12:43 pm
Libera.chat IRC: argonaquila
Location: Paraguay
Contact:

Re: frantOS - my first x86 bare metal project

Post 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.
Prendre soin de sa sante www.viagrasansordonnancefr.com pharmacie de Paris
ArgonAquila
Posts: 15
Joined: Fri Jul 17, 2020 12:43 pm
Libera.chat IRC: argonaquila
Location: Paraguay
Contact:

Re: frantOS - my first x86 bare metal project

Post 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.
Prendre soin de sa sante www.viagrasansordonnancefr.com pharmacie de Paris
Post Reply