Re: Device Manager Draft (incomplete)

"Salvatore Benedetto" <[email protected]> Tue, 8 Apr 2008 21:02:51 +0000
Newsgroups gmane.os.openbeos.kernel.devel
Message-ID <[email protected]>
Hi Axel,

and thanks for finally attacking this :)

On 08/04/2008, Axel Dörfler <[email protected]> wrote:
> Hi there,
>
>  Salvatore just bugged me into sending a first draft of the new device
>  manager stuff. I haven't done that much yet, but it should at least
>  give you an idea about some of the changes, and also the opportunity to
>  comment and influence the design :-)
>  I also had done some more on the missing pieces on a piece of paper I
>  currently can't find again... :-}
>  It's a bit brief, sorry for that. I've started with a test shell to be
>  able to play with a few ideas, and see how it works out in the end.
>
>  -------------8<-------------
>
>  Driver API
>
>  original Be API:
>  init_hardware();
>  init_driver();
>  uninit_driver();
>  uninit_hardware();
>  publish_devices();
>  find_device();
>
>  Current device_manager API:
>  supports_device(parent, noConnection);
>  register_device(parent);
>  init_driver(node, userCookie, *cookie);
>  uninit_driver(cookie);
>  device_removed(node, cookie);
>  device_cleanup(node);
>  get_supported_paths(busses, devices);
>
>  + for busses:
>  register_child_devices(cookie);
>  rescan_bus(cookie);
>
>  Device publishing via devfs node.
>
>  New API:
>  supports_device(parent);
>  register_device(parent);
>  init_driver(node);
>         also publishes any devices/nodes with dedicated calls (ie.
>  devfs_publish_device())
>
>  uninit_driver(node);
>  device_removed(node);
>         any devices and child nodes are removed automatically
>
>  "device" in the API above refers to device_node - maybe rename it, ie.
>  supports_device() to supports_device_node()?
>  Still left out: power management, passive driver matching, identify
>  boot driver
>
>  --
>
>  Device API
>
>  init_device(deviceCookie);
>         called once before one or several open() calls
>  uninit_device(deviceCookie);
>         supposed to free deviceCookie, called when the last reference to
>  the device is closed
>  open(deviceCookie, path, open mode, *cookie);
>         deviceCookie is an object attached to the published device
>
>  close(cookie);
>  free(cookie);
>  read(cookie, pos, buffer, *length);
>  write(cookie, pos, buffer, *length);
>  ioctl(cookie, op, buffer, length);
>         as in BeOS
>
>  io(cookie, io_request);
>         new function to deal with I/O requests directly.
>
>  --
>
>  I/O Requests
>
>  create_io_request(buffer, length, read/write, async, user/kernel);
>  create_io_request_vecs(vecs, count, length, read/write, async, user/
>  kernel);
>         creates the requests and handles copying of the scatter/gather data
>  from userland
>
>  prepare_io_request(request);
>         locks the requests memory and retrieves the physical pages
>
>  map_io_request(request, vecs, count);
>         Returns the buffers of the I/O request mapped into kernel memory.
>
>  prepare_io_request_dma(io request, dmaResource);
>         Map the I/O request to match the DMA requirements of the device.
>         If needed, create a bounce buffer to be used for DMA.
>  get_io_request_memory_map(buffer, io request, vecs, count);
>         Get the memory map of the DMA buffer for this I/O request.
>
>  complete_io_request_dma(io request, dmaResource);
>         Unmaps the data, copies back data from bounce buffer if necessary.
>
>  complete_io_request(request);
>         unlocks/unmaps the memory again
>
>  delete_io_request(request);
>
>  --
>
>  DMA Resource
>
>  create_dma_resource(restrictions);
>         Restrictions are: transfer size, address space, alignment
>
>  dma_buffer_alloc(resource, size)
>  dma_buffer_free(buffer)
>         Allocates or frees memory in that DMA buffer.
>
>  delete_dma_resource(resource);
>
>  -------------8<-------------
>
>  Bye,
>    Axel.
>

What I am more personally interesting in is to understand how
subsystem are supposed to talk to each other. Especialy because of
usb_scsi thing.

Beside describing the API, could you try and post something about how
things fits all together? Remember about the bus factor! :-D

Regards,
-- 
Salvatore Benedetto (a.k.a. emitrax)
Student of Computer Engineer
University of Pisa
www.messinalug.org

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone