4.4. Some Miscellaneous Issues

We had new problems, some would say good problems. We didn't have a bootloader yet, however we needed to pass a command line to the kernel at boot time. We hard-coded the command line into the kernel inside the parse_options(). After that was finished, we made console_init() and serial_console_setup() work the way they should. They no longer ignored the command line, but still RTS and DTR stay low.

Another important issue was memory mapping. The file arch/ppc/mm/init.c contains a function called MMU_init(). This function is actually a big switch statment, divided by the machine type. Each machine maps its memory using the setbat() and ioremap() functions. The BAT mechanism is a way of translating virtual addresses into physical ones. Thus, setbat() is used by specifying a virtual address, a physical address and a page size. Not every size can be used here; you should use one of the finite set of sizes, ranging from 128KB to 256MB. We mapped our IO memory so that virtual equalled physical.

As mentioned, there is another way of mapping memory - ioremap(). ioremap() is used to map physical addresses into virtual ones, making them available to the kernel. The function does not allocate any memory, simply returns a virtual address by which one can access the memory region. The following is a snippet from MMU_init():

case _MACH_mymachine:
	ioremap(UNIVERSE_BASE,UNIVERSE_SIZE);      /* Universe VME */
	ioremap(EEPRO100_BASE,EEPRO100_SIZE);      /* Ethernet EEPRO100 */
As you can see, we don't take the return value of ioremap(). We don't need it, since at this stage the kernel maps the addresses so that virtual address == physical address.