2 Architecture-Specific include/linux Interface

Architectures must implement these interfaces exactly as defined in the include/linux header files.

2.1 <linux/bios32.h>

XXX

2.2 <linux/interrupt.h>

extern unsigned int probe_irq_on(void);
extern int probe_irq_off(unsigned int);

Autoprobing for irqs: probe_irq_on() and probe_irq_off() provide robust primitives for accurate IRQ probing during kernel initialization. They are reasonably simple to use, are not ,,fooled'' by spurious interrupts, and, unlike other attempts at IRQ probing, they do not get hung on stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards). For reasonably foolproof probing, use them as follows:

  1. clear and/or mask the device's internal interrupt.
  2. sti();
  3. irqs = probe_irq_on(); // ,,take over'' all unassigned idle IRQs
  4. enable the device and cause it to trigger an interrupt.
  5. wait for the device to interrupt, using non-intrusive polling or a delay.
  6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
  7. service the device to clear its pending interrupt.
  8. loop again if paranoia is required.

probe_irq_on() returns a mask of snarfed irq's, or 0 on failure.

probe_irq_off() takes the mask as a parameter, and returns the irq number which occurred, or zero if none occurred, or a negative irq number if more than one irq occurred.

2.3 <linux/mm.h>

void show_mem(void);

printk() information about memory usage.

void si_meminfo(struct sysinfo *val);

Dump memory information to val.

2.4 <linux/sched.h>

int request_irq(unsigned int irq,
        void (*handler)(int, void *, struct pt_regs *),
        unsigned long flags, const char *devname, void *dev_id);
void free_irq(unsigned int irq, void *dev_id);

These routines register/unregister interrupt handlers.

irq
is the IRQ number.

handler
is the interrupt handler. It receives the IRQ number, the dev_id (see below) and a struct pt_regs pointer as arguments.

On the i386, passing the registers is pretty pointless: I didn't find a single driver that makes any sensible use of it. (Well, the keyboard driver can print the register values when pressing some hotkey, but I did say sensible use, didn't I?)

flags
The request_irq() routine must understand the following flags (defined in <asm-*/signal.h>):

SA_INTERRUPT
Install a ,,fast'' interrupt handler; fast handlers run with interrupts disabled, and they don't receive a valid pt_regs value.

Otherwise, the handler will be ,,slow:'' Slow handlers run with interrupts enabled. When they return, the kernel should execute bottom halfs, deliver signals and reschedule if necessary.

SA_SHIRQ
Allow this interrupt to be shared with other handlers.

SA_SAMPLE_RANDOM
This interrupt happens unpredictably enough be suitable for random sampling. This is used to help the kernel's random number generator (see also section Interrupts). request_irq() should call rand_initialize_irq(irq) (declared in <linux/random.h>).

devname
A human-readable device name associated with this interrupt.

dev_id
A unique ID associated with this handler, used as a handle to de-install the handler.

(See the Kernel Hacker's Guide for a more verbose description.)

void copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
        struct task_struct * p, struct pt_regs * regs);
void exit_thread(void);
void flush_thread(void);
void dump_thread(struct pt_regs * regs, struct user * dump);
void release_thread(struct task_struct *dead_task);

Copy the current thread with registers regs to p, exit a thread, recycle a thread (i.e., free a thread's resources), release a thread (i.e., free a dead thread that already had been exit_thread()'d) and dump a thread's state into a user strucure, respectively.

2.5 <linux/time.h>

void do_gettimeofday(struct timeval *tv);
void do_settimeofday(struct timeval *tv);

Get/set time using the machine's hardware.

2.6 <linux/vm86.h>

XXX


Michael Hohmuth
March 21, 1996