Page 1 of 2
What would you like to discuss and learn? Just ask!...
Posted: Tue Mar 29, 2016 2:11 pm
by ~
What would you like to learn? We will discuss and explain it here and in other (sub)topics.
What concepts or operating system project would you like to talk about and break down into its most basic components and explanations?
Anything goes, also open source projects to explain from start to end.
It should feel like a small course that we will develop here in the forum and add resources to it.
Re: What would you like to discuss and learn? Just ask!...
Posted: Tue Mar 29, 2016 2:56 pm
by MollenOS
So you are trying to start a forum on a forum? You do know exactly what you are trying to do is why this forum exists. This is like exactly what people are already doing :p Not to burst your bubble tho!
Re: What would you like to discuss and learn? Just ask!...
Posted: Tue Mar 29, 2016 3:02 pm
by moondeck
I dont really understand how memory is allocated after i load my kernel. Say, when i define a variable in my kernels C code, where in memory does it go?
EDIT: Is it in the kernel? say, i call my kmain() from assembly, which is in the .data section of my linker file. Does the C variable reside there? Its not space limited in any way, other than that its its 4K aligned (because i have aligned it). What about variables in assembly? When i defined a GDT, like this
Code: Select all
GDT:
dw something
dd something else
gdt_function:
lgdt[GDT]
How do i know WHERE it actually points to?
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 6:07 am
by Muazzam
Well, since you asked . . .
Wi-Fi is one of the least discussed OS development topics. Has anyone here done it? I guess not. So why not? Can't we port the drivers from other OS or even reverse engineer it?
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 6:12 am
by embryo2
moondeck wrote:I dont really understand how memory is allocated after i load my kernel. Say, when i define a variable in my kernels C code, where in memory does it go?
The bad part about C/C++ developers is they often completely miss the actual processing behind the scene. They think it's cool and smart to use C because it is the preferred language for OS development, it can go low level and the programmer now is as mighty as a god. But C compiler plays a bad joke with the C programmer. It creates an illusion of easiness. So, the programmer just doesn't know where actually his variables are.
I'm far from being C expert but your case is so trivial that even I can tell you that your variables are on the stack unless you have claimed some memory explicitly using something like malloc() or
new in C++.
But next I see you are talking about your kernel. And one of the responsibilities of a kernel developer is the memory management. It seems you are relying the job on the compiler instead of thinking about your own memory manager. And the consequence is crying with your own question - leaving something unanswered makes you feel lost with the very simple problems.
I would recommend you to study a bit about kernel's memory management first and the compiler's memory management second. You can
start here and next follow the links or ask here if something looks too complex to get it after a few readings.
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 6:23 am
by embryo2
Muazzam wrote:Can't we port the drivers from other OS or even reverse engineer it?
Yes we can. Can you start working on it to help the community? What stops you?
Wi-fi has a bit of extra complexity because of the protocols involved and the hardware is nontrivial. I suppose it's essentially more complex than USB. And second problem here is the lack of the unifying standard like is the case for USB. So, if you adopt a driver it doesn't mean everybody can reuse your work, because they should have the same hardware.
To provide some useful information it is required to cover many devices, to find some commonality and to show how different devices extend the common core. Next it is required to cover many protocols involved including such areas as encryption and security as a whole. Only after it all is done it is possible to offer some help to the OS-dev beginners. The only problem here is the time required to do it all.
But may be somebody really has such experience?
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 6:26 am
by moondeck
embryo2 wrote:moondeck wrote:
But next I see you are talking about your kernel. And one of the responsibilities of a kernel developer is the memory management. It seems you are relying the job on the compiler instead of thinking about your own memory manager. And the consequence is crying with your own question - leaving something unanswered makes you feel lost with the very simple problems.
I dont, i just havent developed the MM for my OS yet
https://github.com/m00nd3ck/hydrogen
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 6:38 am
by Solar
Muazzam wrote:Wi-Fi is one of the least discussed OS development topics. Has anyone here done it? I guess not. So why not?
You need:
- a working kernel, memory management and all;
- a working network stack.
I daresay the majority of OSDev visitors aren't at that point yet, so they have no need for WiFi in the first place.
Can't we port the drivers from other OS or even reverse engineer it?
As embryo2 pointed out, no unifying standards. You would be writing
one WiFi driver, for a specific chipset, for one specific OS. All other OS / chipset combinations would still not work.
As for porting a driver... you would need one that is Open Source to begin with. If you're looking at Linux, their drivers reside in kernel space. This means 1) lots of dependencies on the rest of the kernel, not much use to non-Linux kernels which would have to implement a more-or-less complete compatibility layer; 2) intentionally fluctuating kernel / driver API, i.e. future updates to upstream driver code may well imply significant changes to that compatibility layer, and last but not least, 3) GPL...
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 6:53 am
by mikegonta
moondeck wrote:I dont really understand how memory is allocated after i load my kernel. Say, when i define a variable in my kernels C code, where in memory does it go?
EDIT: Is it in the kernel? say, i call my kmain() from assembly, which is in the .data section of my linker file. Does the C variable reside there? Its not space limited in any way, other than that its its 4K aligned (because i have aligned it). What about variables in assembly? When i defined a GDT, like this ...
How do i know WHERE it actually points to?
To access asm variables and functions from linked c:
gcc examples (gcc does not mangle names)
Code: Select all
.global x
x: .long 1
.global asm_function
asm_function:
mov eax, -1
ret
other_asm_function:
mov eax, [C_variable]
mov [x], eax
push eax
call other_C_function
ret
Code: Select all
extern int x; /* tell linker that the variable is external */
int asm_function(void); /* protoype the asm function */
int C_variable; /* global variable */
int C_function(void){
if (x){ /* access the asm variable */
return asm_function; /* invoke the asm function */
}
}
int other_C_function(int var){
return 2 * var;
}
To load code (such as from a boot loader) to a fixed address (for example 0x100000) and then invoke it from C:
Code: Select all
int (*function)(int) = (void *)0x100000;
function(0);
To invoke a function from a function pointer array at a fixed address (for example 0x10000) from C:
Code: Select all
#define function ((int(*)(int)) ((void *)(*(unsigned long *)0x10000)))
function(0);
Of course, the function prototypes should match the actual return and parameter definitions.
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 7:15 am
by Muazzam
embryo2 wrote:Muazzam wrote:Can't we port the drivers from other OS or even reverse engineer it?
Yes we can. Can you start working on it to help the community? What stops you?
What stops me, to be honest, is my experience. Also, my OS is in assembly without POSIX standards. There are many guys here with very advanced Unix-like operating systems, so it'd be a lot easier for them to follow the driver's source code if they want to write their own.
I think, they Wi-Fi is not in their priorities. Maybe, my hobby OS would become famous if managed to write a driver for Wi-Fi?
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 8:16 am
by Roman
variables are on the stack unless you have claimed some memory explicitly using something like malloc() or new in C++.
This is not always true. Global variables reside in statically allocated sections.
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 9:02 am
by embryo2
Muazzam wrote:What stops me, to be honest, is my experience.
...
Maybe, my hobby OS would become famous if managed to write a driver for Wi-Fi?
So, are you expecting someone else to describe you what to do? But have you read about the wi-fi problems? It means you have a small chance of meeting somebody with open source wi-fi code and ready to tell you about it. And if there's somebody, who managed to write a driver for wi-fi, then how can you become famous?
May be in your situation it is better to ask about Linux kernel driver development. Next you can get the Linux sources and try to understand how a particular wi-fi driver works (or even better to start with something much simpler). And then you'll be able to port the driver to your OS. Of course, you should pay attention to the availability of an open source wi-fi driver for your hardware.
Are you scared about the efforts required?
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 9:05 am
by embryo2
Roman wrote:variables are on the stack unless you have claimed some memory explicitly using something like malloc() or new in C++.
This is not always true. Global variables reside in statically allocated sections.
May be, I'm Java fan.
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 9:49 am
by iansjack
Muazzam wrote:Also, my OS is in assembly without POSIX standards.
A choice which makes it an order of magnitude less likely that you will write a Wi-Fi driver.
I'm sure that you have good reasons for wanting to write your OS in assembly (actually, that's a lie; I'm pretty sure that you don't have a
good reason for this choice) but you have to appreciate the extra difficulties that this choice involves.
Re: What would you like to discuss and learn? Just ask!...
Posted: Wed Mar 30, 2016 10:22 am
by BrightLight
Lately, I'm into AHCI and networking.
I'm building an AHCI driver based on the info on the Wiki, but there seems to be quite little networking info.