OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Mar 18, 2024 8:04 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: New MicroKernel in FreeBasic
PostPosted: Sun May 30, 2021 2:14 pm 
Offline
Member
Member

Joined: Tue Mar 25, 2008 12:26 pm
Posts: 52
I am glad to announce you that i finaly managed to evolve my os kernel to an (almost) true MicroKernel in freebasic (yes yes):

Attachment:
File comment: screenshot
onyx_screenshot.PNG
onyx_screenshot.PNG [ 112.39 KiB | Viewed 10166 times ]


* Now there is a interface API that allow the user process to handle interrupts. they tell the kernel the address of the method to call. then they should wait for an event.
* When an user handled interrupt occurs, the kernel put the request to a queue for that irq number. it will wake the owner thread up if it was waiting, (else it will left the request to the queue, and will be dequeued when the thread will be "waiting")
* When the kernel wakes the thread up, it pass the general registers to the stack of the thread, to pass them as function parameters, and changes the eip of the thread , so the method will run in the next schedule
* the user process can then do his job , and eventually modify the value of his stack (the kernel will then copy them to the "caller" thread, so he can receive returns value)

* there is also a concept of "user mode device" wich are like the interrupt handler: the thread says the kernel to create a "device" and give it an name and a descriptor (an integer wich is mainingfull only for that thread). he also give to the kernel the address of the method to call when an invoke on that device is done.
* when a process want to comunicate with the device driver, it first ask the kernel to find descriptor of the device (using its name). then it can ask the kernel to invoke the device driver by giving it the descriptor and the parameters.
* the kernel will then make the caller "waiting for reply" and wake up the device thread at the correct address

with that two concepts i managed to implement:
* user mode GUI server: it exposes it services by handling an interrupt number
* user mode driver for the keyboard and the mouse (in the GUI Server, there is 2 thread that handle the interrupt 0x20 and 0x2C to get signals from the keyboard and the mouse)

* user mode driver for the hard drive: it exposes it services using the user mode device driver interface
* user mode VFS and FAT file system: it exposes it services trought another interrupt

* Note : the kernel also provide a mechanism for the called process to map memory from/to the caller into/From his address space, in this way it can easyly copy strings (to get a button text, or a file name to open), map a buffer to the client (so he can draw on it), copy data to the client (when FileRead is called by example)

* To launch a program, the process should first load the executable into his memory, then call the kernel to create a new process using that address (the kernel will then copy it to this address space, and create a new process from it)


* i cleaned them the kernel code to remove everyting about the gui, the devices drivers, the virtual file system (and the fat file system implementation)
* the only things that remains are : the GDT initialization, the IDT initialisation, the Interrupt management , the thread management and scheduling
* the hard disk , the virtual system, and the init process are loaded by grub , and the kernel will use that to create the first processes
* to enter in graphic mode, i prepared an embedded module who is moved into the lower memory, and the kernel will use it to jump into realmode to initialize the graphic mode; this is almos the only execption to the "microkernel" structure i thing



Note: Everything is done using FreeBasic, i used my previous OS as base and made it evolved little to little to achive this. i shoud thank the creator of the Frost OS (wich is also in freebasic) from wich i took the Virtual memory management
the sources codes are on github at https://github.com/stephaneweg/onyx-kernel


Top
 Profile  
 
 Post subject: Re: New MicroKernel in FreeBasic
PostPosted: Mon May 31, 2021 4:02 am 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 am
Posts: 399
trolly wrote:
I am glad to announce you that i finaly managed to evolve my os kernel to an (almost) true MicroKernel in freebasic (yes yes):


Documentation looks a bit sparse, so I'll start you off with some potential FAQ entries. (Genuine questions):

Why FreeBASIC?

Does it confer any advantages over C/C++?

What did you find easier or more difficult compared to more traditional system implementation languages?


Top
 Profile  
 
 Post subject: Re: New MicroKernel in FreeBasic
PostPosted: Mon May 31, 2021 12:57 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
thewrongchristian wrote:
trolly wrote:
I am glad to announce you that i finaly managed to evolve my os kernel to an (almost) true MicroKernel in freebasic (yes yes):


Documentation looks a bit sparse, so I'll start you off with some potential FAQ entries. (Genuine questions):

Why FreeBASIC?

Does it confer any advantages over C/C++?

What did you find easier or more difficult compared to more traditional system implementation languages?

I second the question of "Why FreeBasic?" From what I've seen, FreeBasic is just C with a new syntax. But I haven't used it in years so...


Top
 Profile  
 
 Post subject: Re: New MicroKernel in FreeBasic
PostPosted: Tue Jun 01, 2021 5:12 am 
Offline

Joined: Wed Aug 05, 2020 3:38 pm
Posts: 9
I never expected to see BASIC render anything that's not squares and lines in 16 colors. Good work!


Top
 Profile  
 
 Post subject: Re: New MicroKernel in FreeBasic
PostPosted: Wed Jun 02, 2021 3:58 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Ethin wrote:
I second the question of "Why FreeBasic?" From what I've seen, FreeBasic is just C with a new syntax. But I haven't used it in years so...

It's the opposite: FreeBasic is based on quickbasic (and can actually compile quickbasic with the appropriate command line flags) with the addition of pointer types, so you still get memory safety with native strings and bounds-checked arrays when you write normal BASIC code. These features obviously don't come for free, so you end up using raw pointers initially in a "c-style" kernel until at least the point where you have a working memory allocator. So of course in every FreeBasic kernel project you are going to see the awkward version of the language first, before you get to the point where you can support the standard library and go back to idiomatic code.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: New MicroKernel in FreeBasic
PostPosted: Wed Jun 02, 2021 1:45 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
Oh, I didn't know that. I thought it was something like PureBASIC, which is essentially C with a bloated standard library and an almost non-existent community.


Top
 Profile  
 
 Post subject: Re: New MicroKernel in FreeBasic
PostPosted: Sat Jun 05, 2021 7:03 pm 
Offline
Member
Member

Joined: Tue Mar 25, 2008 12:26 pm
Posts: 52
thewrongchristian wrote:
Why FreeBASIC?


Just because i like this language, i learned programing with QBASIC, in the past i did somme gui with it (look by example at http://q-step.theguiblog.com)

The toolchain was also easy to set-up in windows (it is included in the github repository)

i use also FASM for the asm part (the mutliboot header ,and the interrupts stubs)

BTW i am a c# developer, and in the past i already made a kernel in ASM and another in C .


The next step would be to port the FreeBasic Compiler to my os, but for that i have to port GCC, GAS, LD, etc....
i already ported FASM to my os


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

All times are UTC - 6 hours


Who is online

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