OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:42 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: frantOS - my first x86 bare metal project
PostPosted: Tue Jul 21, 2020 8:35 am 
Offline
User avatar

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


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Wed Jul 22, 2020 5:31 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Wed Jul 22, 2020 5:44 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Wed Jul 22, 2020 4:17 pm 
Offline
User avatar

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


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Thu Jul 23, 2020 7:38 pm 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 am
Posts: 401
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.


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Fri Jul 24, 2020 6:59 am 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
Here some name suggestions:
"frantoengine"
"frantogfx"
"frantostic"

Greetings
Peter


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Sat Jul 25, 2020 7:29 am 
Offline

Joined: Fri Jul 17, 2020 12:43 pm
Posts: 15
Location: Paraguay
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


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Sat Jul 25, 2020 8:30 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Sat Jul 25, 2020 9:34 am 
Offline

Joined: Fri Jul 17, 2020 12:43 pm
Posts: 15
Location: Paraguay
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


Top
 Profile  
 
 Post subject: Re: frantOS - my first x86 bare metal project
PostPosted: Sat Jul 25, 2020 9:43 am 
Offline

Joined: Fri Jul 17, 2020 12:43 pm
Posts: 15
Location: Paraguay
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 21 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