HAL

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.
Post Reply
User avatar
AndrewAPrice
Member
Member
Posts: 2327
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

HAL

Post by AndrewAPrice »

I'm wondering the best way to work on my HAL.

But I'm stuck on the following thoughts:

If my drivers are loadable modules I want to dynamically link them with a driver library (which exposes sections of the kernel most useful for driver development). Except to load the dynamic library I need a disk driver and an FS driver, which are dynamically linked to the library. If I don't use a dynamic library, how will drivers know the location of kernel functions and classes? (I want to try to keep away from kernel<->kernel interrupts unless absolutely necessary.)

How do I handle DMA, USB, etc within drivers? My OS has a DMA driver, and I'm trying to think of a way I can neatly handle things like DMA and USB and making them accessible through my disk drivers with a consistant interface.
My OS is Perception.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

I would think of an hierarchical structure. A driver for an USB device would include calls to a USB driver.

Or in monospaced font: :wink:

Code: Select all

USB controller
 |
SD card
 |
VFS
 |
FAT
"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 ]
User avatar
AndrewAPrice
Member
Member
Posts: 2327
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

How would I manage different types of hardware dependencies (how would one driver find my DMA or USB driver?)

You would need some sort of name the other drivers could look up, e.g. "DMA" "USB".

Suddenly the Unix philosophy that everything is a file makes a lot of sense.

Anyway, what is the best way for module code to interact with kernel code?
My OS is Perception.
Jeffrey
Posts: 20
Joined: Fri Jul 27, 2007 1:35 pm
Location: Virginia, USA

Post by Jeffrey »

Well the Windows kernel uses a technique of tagging objects/pages with 4 to 5 letter names. Memory reserved for PNP is tagged PNP[0-...], etc. You could define classes of devices and drivers and have the driver identify themselves with what category they belong to. But doing it that way places limitations on your code, as drivers will only look for a device that has codename x, etc. Just a thought.
User avatar
AndrewAPrice
Member
Member
Posts: 2327
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

That would be the best way to go (FLOPPY0, FLOPPY1, DMA8, DMA16, etc). I'm going with a mixed mono/microkernel-ish route; drivers will run in user-space, while VFS, FS, will be in kernel-space.

Drivers will run like regular programs (except as super user) and the kernel will use IPC to communicate. I still need to work out a standard system of how a driver can access an area of memory in the kernel (DMA, video buffers, etc), unless drivers are allowed to map anywhere in physical memory to their address space.

Hmm... I still need to work out how I can transfer a large block of data from one driver into another.
My OS is Perception.
Post Reply