[openbeos] Re: driver stuff

  • From: "David Reid" <mail@xxxxxxxxxxxxxx>
  • To: <openbeos@xxxxxxxxxxxxx>
  • Date: Tue, 30 Apr 2002 21:03:13 +0100

I'd like to see us add a bcopy and the other b* functions (optimised nicely)
to kernel space as they should deliver a small performance boost. Other than
that, I think your idea is a good one, though bsd kernels also have
copyin/copyout functions to get data into/out of the kernel space.

With Michael being bogged down in usb land the kernel fork date seems to be
moving slowly away :(

david

----- Original Message -----
From: "François Revol" <revol@xxxxxxx>
To: <openbeos@xxxxxxxxxxxxx>
Sent: Tuesday, April 30, 2002 8:24 PM
Subject: [openbeos] driver stuff


>
> Someone on BeShare just mentionned to me the existance of a bunch of
functions
> in libroot that are known to belong to the kerneland PCI/ISA modules.
>
> [revol@patrick /boot/home/devel/obos/commands]$ nm
/system/lib/libroot.so|grep isa_
> 00055f1c T read_isa_io
> 00055f24 T write_isa_io
> [revol@patrick /boot/home/devel/obos/commands]$ nm
/system/lib/libroot.so|grep pci_
> 00055c04 T get_nth_pci_info
> 00055be4 T read_pci_config
> 00055bec T write_pci_config
>
> as I've been told, those use system calls to access thoses calls that are
> presumably made against the kernel instance of the pci and isa modules.
>
> strings /system/lib/libroot.so|grep misc
> tells nothing that would look like /dev/misc/config (the device driver
listdev
> uses to access the same calls. I've been told also those libroot calls
were
> public in R4 maybe. I would like whoever is to be implementing part of
> libroot not to use the syscalls, but to open("/dev/misc/config"); this
would
> be both cleaner and consistend with multi-user stuff in the future (easier
to
> chmod a device entry than it is to check the user in the syscall).
>
>
> Another thing about drivers...
> Although NewOS still uses the 2 GB kernel/ 2 GB user scheme, it isn't said
it
> won't switch away from this some day...
>
> I'd suggest anyone writing drivers up to now to use those simple macros,
not
> very hard, but surely will make switching easier in the future
> (there are other issues, but most of the drivers should compile OoTB)
> just put them at the top of your source (or the corresponding header file)
>
> #ifndef DONT_TOUCH_USERSPACE
> // copy data from kernel space to user space
> # define copy_to_user(dst, src, len) memcpy(dst, src, len)
> // copy data from user space to kernel space
> # define copy_from_user(dst, src, len) memcpy(dst, src, len)
> // get a kernel address from a user address (if possible)
> # define user_to_kernel(addr) (addr)
> // get a user address from a kernel address (if possible)
> # define kernel_to_user(addr) (addr)
> #endif
>
> and do
>
> read_hook(..., char *p, ...)
> {
> ...
>     copy_to_user(p, my_kernel_buffer, to_copy);
>     // instead of memcpy(p, my_kernel_buffer, to_copy);
> ...
> }
>
>
> If you have a better suggestion maybe ?
>
> François.
>


Other related posts: