when to do ioremap?
Garcia Jérémie
GARCIAJ at 3il.fr
Wed Mar 30 01:10:42 EST 2005
Ladies and Gentlemen,
Even if I am a Linux kernel newbie, I'm in charge of adapting a Montavista LSP (designed for the IBM 405EP evaluation board) to our propietary hardware which uses a 405EP too.
So, I created both files /arch/ppc/platforms/myBoard.c and myBoard.h first copying the LSP files and then modifying them.
However, you guess that our mapping is very different from the one used by the IBM eval board. The fact is that I'm not at all familiar with memory management (I'm a part time student/worker) and I try to understand the board_setup_arch function provided by the LSP (cf. below). I understand that the ioremap allows us to build new page tables mapping physical addresses on a range of contiguous (linear) virtual addresses. But why are we doing that at that early boot time and not in a driver at a wanted time? In the IBM eval board case, only 2 fpga registers are used but on my board, we are using up to 4K for our I/O space (segmented in 4 different part -> ex: engineer_purpose_regs,appli_regs, asic_regs,..). Then we have a software that must play with those registers from the user-space.
So could you explain me the original file to help me coding the new one. I definitely don't understand what are the consequences of that (the function return is void,nothing is done with the returns of ioremap calls except test). Does it allow us to do something later? Couldn't we do all of that in a driver or is there a serious reason to do it here?
void __init
board_setup_arch(void)
{
#define EVB405EP_FPGA_BASE 0xF0300000
void *fpga_reg0;
void *fpga_reg1;
evb405ep_early_serial_map();
fpga_reg0 = ioremap(EVB405EP_FPGA_BASE, 8);
if (!fpga_reg0) {
printk(KERN_CRIT
"evb405ep_setup_arch() fpga_reg0 ioremap failed\n");
return;
}
fpga_reg1 = fpga_reg0 + 1;
}
Hoping that the question is not too stupid : tks a lot everyone for helping a student lost in the linux kernel sources... :-)
More information about the Linuxppc-dev
mailing list