arm:no longer rely on a 1:1 phys mapping for device memory.

Change-Id: Ie3f61069f882c37dbb81dee813fdfd883e7468cf
This commit is contained in:
Kees Jongenburger
2013-06-11 16:07:43 +02:00
committed by Gerrit Code Review
parent a74251eb16
commit a5a693a046
6 changed files with 220 additions and 5 deletions

View File

@@ -53,6 +53,67 @@ extern void * k_stacks;
+ 2 * ((cpu) + 1) * K_STACK_SIZE))
/*
* Definition of a callback used when a memory map changes it's base address
*/
typedef int (*kern_phys_map_mapped)(vir_bytes id, vir_bytes new_addr );
/*
* struct used internally by memory.c to keep a list of
* items to map. These should be staticaly allocated
* in the individual files and passed as argument.
* The data doesn't need to be initialized. See omap_serial for
* and example usage.
*/
typedef struct kern_phys_map{
phys_bytes addr; /* The physical address to map */
vir_bytes size; /* The size of the mapping */
vir_bytes id; /* an id passed to the callback */
kern_phys_map_mapped cb; /* the callback itself */
phys_bytes vir; /* The virtual address once remapped */
int index; /* index */
struct kern_phys_map *next; /* pointer to the next */
} kern_phys_map ;
/*
* Request an in kernel physical mapping.
*
* On ARM many devices are memory mapped and some of these devices
* are used in the kernel. These device can be things like serial
* lines, interrupt controller and clocks. The kernel needs to be
* able to access these devices at the various stages of booting.
* During startup, until arch_enable_paging is called, it is the
* kernel whom is controlling the mappings and it often needs to
* access the memory using a 1:1 mapping between virtual and
* physical memory.
*
* Once processes start to run it is no longer desirable for the
* kernel to have devices mapped in the middle of the process
* address space.
*
* This method requests the memory manager to map base_address/size
* in the kernel address space and call back the kernel when this
* mapping takes effect (after enable_paging).
*
* Before the callback is called it is up to the kernel to use it's
* own addressing. The callback will happen *after* the kernel lost
* it's initial mapping. It it therefore not safe to use the initial
* mapping in the callback. It also is not possible to use printf for
* the same reason.
*/
int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size,
kern_phys_map * priv, kern_phys_map_mapped cb,
vir_bytes id);
/*
* Request a physical mapping and put the result in the given prt
* Note that ptr will only be valid once the callback happend.
*/
int kern_phys_map_ptr( phys_bytes base_address, vir_bytes io_size,
kern_phys_map * priv, vir_bytes ptr);
/* functions defined in architecture-independent kernel source. */
#include "kernel/proto.h"