2009/11/13 Joel Fernandes <agnel.joel@xxxxxxxxx>: >> Thanks for your replied. I surveyed in the internet and found the >> kerenl's kmalloc API also return a continuous memory address. Is it >> right? So there are two kernel APIs (__get_free_page, kmalloc) return >> a _continuous_ memory address (virtual address) and it can be convert >> to physical address by virt_to_phys(). > > Yes that's right, AFAIK kmap allocates physically contiguous memory > and vmalloc allocates virtual contiguous memory. Actually the 2 > functions you're pointing out (__get_free_page and kmalloc) are not > independent. At its heart, the kernel allocator is page based so > kmalloc uses the same page based functions to allocate is memory - > infact the kmalloc interface is built on top of the slab layer (which > uses the page allocation functions to allocate memory), get_free_page > is just at a much lower level. > > Out of curiosity, why do you need the physically addresses of the > memory you're allocating for your particular application? > > Regards, > -Joel > Okay, let me describe.: ) The main purpose is to upgrade BIOS firmware under Linux. First, user app allocates a 64KB size memory filled with part of BIOS firmware binary code then call ioctl (it pass 64KB memory addr and block number). In the ioctl function, driver also allocates a 64KB continuous memory and get it's physical address then use copy_from_user function to copy user space 64KB data to kernel space. After prepare it, driver fills two register (ebx, ecx) with physical continuous addr and block number then triggers SMI (system menagement interrupt). The BIOS do related SMI hook, it will copy 64KB from physical continuous addr (ebx) to BIOS code block (ecx). So I must make sure to pass physical memory addr to BIOS otherwise BIOS will get wrong binary code or crashes. BTW, should I need to store ebx, ecx before I used it then restore it after finish SMI hook? BRs H. Johnny -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ