Once you have written a handler function, you need to register it with startup and allocate the required system RAM for your data area. This can be accomplished with the following functions:
paddr_t alloc_ram(phys_addr, size, alignment); int mdriver_add(name, interrupt, handler, data_paddr, data_size);
Since you're allocating memory and passing an interrupt, these functions must be called after RAM is initialized by calling init_raminfo(), and after the interrupt information is added to the system page by calling init_intrinfo().
The main() function of startup main.c looks like as follows:
... paddr_t mdrvr_addr; ... /* * Collect information on all free RAM in the system. */ init_raminfo(); // // In a virtual system we need to initialize the page tables // if(shdr->flags1 & STARTUP_HDR_FLAGS1_VIRTUAL) init_mmu(); /* * The following routines have hardware or system dependencies which * may need to be changed. */ init_intrinfo(); mdrvr_addr = alloc_ram(~0L, 65535, 1); /* make our 64 k data area */ mdriver_add("mini-data", 0, mini_data, mdrvr_addr, 65535); ...
In this example, we have allocated 64 KB of memory and registered our minidriver handler function with the name mini-data.