next up previous contents index
Next: 29.5.4 Directory Structure Up: 29.5 Internals Previous: 29.5.2 Variables

29.5.3 Functions

autoirq_setup
int autoirq_setup(int waittime);

This function is called by a driver to set up for probing IRQs. The function attaches a handler on each available IRQ, waits for waittime ticks, and returns a bit mask of IRQs available IRQs. The driver should then force the device to generate an interrupt.

autoirq_report
int autoirq_report(int waittime);

This function is called by a driver after it has programmed the device to generate an interrupt. The function waits waittime ticks, and returns the IRQ number on which the device interrupted. If no interrupt occurred, 0 is returned.

register_blkdev
int register_blkdev(unsigned major, const char *name, struct file_operations *fops);

This function registers a driver for the major number major. When an access is made to a device with the specified major number, the kernel accesses the driver through the operations vector fops. The function returns 0 on success, non-zero otherwise.

unregister_blkdev
int unregister_blkdev(unsigned major, const char *name);

This function removes the association between a driver and the major number major, previously established by register_blkdev. The function returns 0 on success, non-zero otherwise.

getblk
struct buffer_head *getblk(kdev_t dev, int block, int size);

This function is called by a driver to allocate a buffer size bytes in length and associate it with device dev, and block number block.

brelse
void brelse(struct buffer_head *bh);

This function frees the buffer bh, previously allocated by getblk.

bread
struct buffer_head *bread(kdev_t dev, int block, int size);

This function allocates a buffer size bytes in length, and fills it with data from device dev, starting at block number block.

block_write
int block_write(struct inode *inode, struct file *file, const char *buf, int count);

This function is the default implementation of file write. It is used by most of the Linux block drivers. The function writes count bytes of data to the device specified by i_rdev field of inode, starting at byte offset specified by f_pos of file, from the buffer buf. The function returns 0 for success, non-zero otherwise.

block_read
int block_read(struct inode *inode, struct file *file, const char *buf, int count);

This function is the default implementation of file read. It is used by most of the Linux block drivers. The function reads count bytes of data from the device specified by i_rdev field of inode, starting at byte offset specified by f_pos field of file, into the buffer buf. The function returns 0 for success, non-zero otherwise.

check_disk_change
int check_disk_change(kdev_t dev);

This function checks if media has been removed or changed in a removable medium device specified by dev. It does so by invoking the check_media_change function in the driver's file operations vector. If a change has occurred, it calls the driver's revalidate function to validate the new media. The function returns 0 if no medium change has occurred, non-zero otherwise.

request_dma
int request_dma(unsigned drq, const char *name);

This function allocates the DMA request line drq for the calling driver. It returns 0 on success, non-zero otherwise.

free_dma
void free_dma(unsigned drq);

This function frees the DMA request line drq previously allocated by request_dma.

disable_irq
void disable_irq(unsigned irq);

This function masks the interrupt request line irq at the interrupt controller.

enable_irq
void enable_irq(unsigned irq);

This function unmasks the interrupt request line irq at the interrupt controller.

request_irq
int request_irq(unsigned int irq, void (*handler)(int, struct), unsigned long flags, const char *device);

This function allocates the interrupt request line irq, and attach the interrupt handler handler to it. It returns 0 on success, non-zero otherwise.

free_irq
void free_irq(unsigned int irq);

This function frees the interrupt request line irq, previously allocated by request_irq.

kmalloc
void *kmalloc(unsigned int size, int priority);

This function allocates size bytes memory. The priority argument is a set of bitfields defined as follows:

GFP_BUFFER
Not used by the drivers.
GFP_ATOMIC
Caller cannot sleep.
GFP_USER
Not used by the drivers.
GFP_KERNEL
Memory must be physically contiguous.
GFP_NOBUFFER
Not used by the drivers.
GFP_NFS
Not used by the drivers.
GFP_DMA
Memory must be usable by the DMA controller. This means, on the x86, it must be below 16 MB, and it must not cross a 64K boundary. This flag implies GFP_KERNEL.

kfree
void kfree(void *p);

This function frees the memory p previously allocated by kmalloc.

vmalloc
void *vmalloc(unsigned long size);

This function allocates size bytes of memory in kernel virtual space that need not have underlying contiguous physical memory.

check_region
int check_region(unsigned port, unsigned size);

Check if the I/O address space region starting at port and size bytes in length, is available for use. Returns 0 if region is free, non-zero otherwise.

request_region
void request_region(unsigned port, unsigned size, const char *name);

Allocate the I/O address space region starting at port and size bytes in length. It is the caller's responsibility to make sure the region is free by calling check_region, prior to calling this routine.

release_region
void release_region(unsigned port, unsigned size);

Free the I/O address space region starting at port and size bytes in length, previously allocated by request_region.

add_wait_queue
void add_wait_queue(struct wait_queue **q, stuct wait_queue *wait);

Add the wait element wait to the wait queue q.

remove_wait_queue
void remove_wait_queue(struct wait_queue **q, struct wait_queue *wait);

Remove the wait element wait from the wait queue q.

down
void down(struct semaphore *sem);

Perform a down operation on the semaphore sem. The caller blocks if the value of the semaphore is less than or equal to 0.

sleep_on
void sleep_on(struct wait_queue **q, int interruptible);

Add the caller to the wait queue q, and block it. If interruptible flag is non-zero, the caller can be woken up from its sleep by a signal.

wake_up
void wake_up(struct wait_queue **q);

Wake up anyone waiting on the wait queue q.

wait_on_buffer
void wait_on_buffer(struct buffer_head *bh);

Put the caller to sleep, waiting on the buffer bh. Called by drivers to wait for I/O completion on the buffer.

schedule
void schedule(void);

Call the scheduler to pick the next task to run.

add_timer
void add_timer(struct timer_list *timer);

Schedule a time out. The length of the time out and function to be called on timer expiry are specified in timer.

del_timer
int del_timer(struct timer_list *timer);

Cancel the time out timer.


next up previous contents index
Next: 29.5.4 Directory Structure Up: 29.5 Internals Previous: 29.5.2 Variables

University of Utah Flux Research Group