What would you like to discuss and learn? Just ask!...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

What would you like to discuss and learn? Just ask!...

Post 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.
MollenOS
Member
Member
Posts: 202
Joined: Wed Oct 26, 2011 12:00 pm

Re: What would you like to discuss and learn? Just ask!...

Post 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!
User avatar
moondeck
Member
Member
Posts: 56
Joined: Sat Dec 19, 2015 12:18 pm
Libera.chat IRC: moondeck
Location: The Zone, Chernobyl

Re: What would you like to discuss and learn? Just ask!...

Post 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?
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: What would you like to discuss and learn? Just ask!...

Post 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?
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: What would you like to discuss and learn? Just ask!...

Post 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.
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: What would you like to discuss and learn? Just ask!...

Post 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?
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
User avatar
moondeck
Member
Member
Posts: 56
Joined: Sat Dec 19, 2015 12:18 pm
Libera.chat IRC: moondeck
Location: The Zone, Chernobyl

Re: What would you like to discuss and learn? Just ask!...

Post 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 :D

https://github.com/m00nd3ck/hydrogen
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What would you like to discuss and learn? Just ask!...

Post 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...
Every good solution is obvious once you've found it.
mikegonta
Member
Member
Posts: 229
Joined: Thu May 19, 2011 5:13 am
Contact:

Re: What would you like to discuss and learn? Just ask!...

Post 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.
Mike Gonta
look and see - many look but few see

https://mikegonta.com
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: What would you like to discuss and learn? Just ask!...

Post 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? :D
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: What would you like to discuss and learn? Just ask!...

Post 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.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: What would you like to discuss and learn? Just ask!...

Post 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? :D
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?
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: What would you like to discuss and learn? Just ask!...

Post 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.
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: What would you like to discuss and learn? Just ask!...

Post 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.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: What would you like to discuss and learn? Just ask!...

Post 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.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Post Reply