Posts

Showing posts from May, 2010

LDD3 notes: Driver Model

My notes while reading Linux Device Drivers 3rd edition . 2.6 device model addresses aspects common to all types of devices: Power management Userspace communications /sysfs Hotplugging w/ udev Device classes Object lifecycle Kobject, Kset, Subsystem kobject per object, belongs to a ktype. kset for a collection of kobjects of same type Subsystem as a high-level portion of the kernel as a whole: block, devices, usb, pci Class as high-level view of what a device does Kobject embed struct kobject in your structure initialize name, ktype, kset and parent implement a destructor (release) implement reference counting by wrapping kobject_{get|put} back-cast kobject references to your structure using using container_of() Adding a Kobject to a Kset point kobject.kset to set point kobject.parent to the set kobject_register() Subsystem a kset with a semaphore rooted at the top of the sysfs hierarchy subsystem_{init|register|unregister|get|put} Bus, Device , Driver , Class , Class device Bus as a

LDD3 notes: USB

My notes while reading Linux Device Drivers 3rd edition . General naming: root_hub-hub_port[-hub_port]:config.interface write to bConfigurationValue will switch configuration & bound driver URBs skbuff analogy queued, async, acknowledged usb_alloc_urb(), usb_fill_[int|bulk]_urb(), usb_submit_urb() transfer buffers must be kmalloc():ed, not static or automatic device_id's can match specific vendor/product whole device class / subclass /protocol individual interface class MODULE_DEVICE_TABLE(usb, usb_device_id table)

vmware player network configuration

Vmware player 3.0.1 is a surprisingly capable and free virtualization environment. "Player" in the name is a bit misleading as many of the restrictions in earlier versions have been lifted. However, network configuration tool is not installed by default and needs to be manually extracted. Richard at f5 devcentral provides the details: You can install it manually by extracting it from the install file. VMware-player-3.0.1-227600.exe /e .\vmwareextract Open network.cab and copy vmnetcfg.exe to the root of your player install. You now have a nice graphical editor for your virtual network.

LDD3 notes: Data types

My notes while reading Linux Device Drivers 3rd edition . size_t vs ssize_t for negative values as error codes C99 [u]intptr_t, integer which would fit a pointer. Not used in Linux. Similar to eCos cyg_addrword. fixed size integers u8..s32 within kernel ioctl structures shared with userspace use prefix __u8 _t Typedefs for portability only out of fashion inconvenient printk use Important constants: HZ. PAGE_SIZE/SHIFT Endianness cpu_to_le32() .. be64_to_cpu() Padding force struct to match hardware expectations, without padding for performance: __attribute__ ((packed)) Error codes in pointers ERR_PTR() -> IS_ERR() -> PTR_ERR() Lists list_del_init() - re-init for future re-insertion list_for_each_entry() - foreach and list_entry combined

LDD3 notes: Memory

My notes while reading Linux Device Drivers 3rd edition . Allocation Flags - GFP_KERNEL - system call, i.e. behalf of a process running in kernel -> may sleep - GFP_ATOMIC - won't sleep, but has limited memory available Slab caches for quick allocation of constant size objects ( == object pool ) - a.k.a lookaside cache - ctor/dtor can be called in atomic context, indicated by a flag Mempool - a wrapper for slab cache which keeps some free memory ready - try to avoid vmalloc contiguous region of virtual memory non-hardware related work only, like loading modules arbitrary size GFP_KERNEL internally, cannot use in atomic context limited address space available, avoid. kmalloc arbitrary size contiguous region of physical memory with 1:1 mapped virtual addresses get_free_page[s]() & get_order() power of 2 number of pages more than 1 is failure prone with 1:1 mapped virtual addresses alloc_pages() indirect access through struct page get/put_cpu_var() good for cou

Insert a picture by reference in MS Word

I've always disliked manual, repetitive tasks with MS Word. There is one less to worry about, now that I've found about inserting and linking pictures. In insert picture file dialog, select "Insert and Link", to make a link referencing the original file to keep it automatically updated when the picture changes. have an embedded copy in the document to avoid broken links when sending out the Word document. How to Insert Images in a Word Document without Embedding