- ;------------------------------------------------------------------------------
- ;
- ; File: memory_cfg.inc
- ;
- ; This file is used to define g_oaladdresstable. This table is passed
- ; Kernelstart To estabilish physical to virtual memory mapping. This table
- ; Is used also in iomem oal module to map between physical and virtual
- ; Memory addresses via oalpatova/oalvatopa functions.
- ;
- ;------------------------------------------------------------------------------
- ; Export Definition
- Export g_oaladdresstable [Data]
- ;------------------------------------------------------------------------------
- ;
- ; Table format
- ; Cached address, physical address, size
- ;------------------------------------------------------------------------------
- G_oaladdresstable
- DCD 0x80000000, 0x30000000, 64; 32 mb dram Bank 6
- DCD 0x84000000, 0x10000000, 32; ngcs2: PCMCIA/pccard
- DCD 0x86000000, 0x18000000, 32; 32 MB srom (SRAM/ROM) Bank 3
- DCD 0x88000000, 0x20000000, 32; 32 MB srom (SRAM/ROM) Bank 4
- DCD 0x8a000000, 0x28000000, 32; 32 MB srom (SRAM/ROM) Bank 5
- DCD 0x8c000000, 0x08000000, 32; 32 MB srom (SRAM/ROM) Bank 1
- DCD 0x90800000, 0x48000000, 1; memory control register
- DCD 0x90900000, 0x49000000, 1; USB Host register
- DCD 0x90a00000, 0x4a000000, 1; interrupt control register
- DCD 0x90b00000, 0x4b000000, 1; DMA control register
- DCD 0x90c00000, 0x4c000000, 1; clock & Power register
- DCD 0x90d00000, 0x4d000000, 1; LCD control register
- DCD 0x90e00000, 0x4e000000, 1; NAND Flash control register
- DCD 0x90f00000, 0x4f000000, 1; camera control register
- DCD 0x91000000, 0x50000000, 1; UART control register
- DCD 0x91100000, 0x51000000, 1; PWM timer register
- DCD 0x91200000, 0x52000000, 1; USB device register
- DCD 0x91300000, 0x53000000, 1; watchdog timer register
- DCD 0x91400000, 0x54000000, 1; IIC control register
- DCD 0x91500000, 0x55000000, 1; IIS control register
- DCD 0x91600000, 0x56000000, 1; I/O port register
- DCD 0x91700000, Zero X 57000000, 1; RTC control register
- DCD 0x91800000, 0x58000000, 1; A/D convert register
- DCD 0x91900000, 0x59000000, 1; SPI register
- DCD 0x91a00000, 0x5a000000, 1; SD interface register
- DCD 0x92000000, 0x00000000, 32; 32 MB srom (SRAM/ROM) Bank 0
- DCD 0x00000000, 0x00000000, 0; end of table
- ;------------------------------------------------------------------------------
- End
In the past, I never knew what was going on with this table. I had a chance to call his function.
C: \ wince500 \ platform \ common \ SRC \ Arm \ common \ Memory. c
- //------------------------------------------------------------------------------
- //
- // File: memory. c
- // The code shows the relationship between the arm virtual memory and the physical memory.
- // Memory interface routines.
- //
- # Include <windows. h>
- # Include <oal_log.h>
- # Include <oal_memory.h>
- Typedef struct {
- Uint32 CA; // cached virtual address
- Uint32 Pa; // physical address
- Uint32 size; // size, in MB bytes
- } Oal_address_table, * poal_address_table;
- //------------------------------------------------------------------------------
- //------------------------------------------------------------------------------
- //
- // Function: oalpatova
- //
- // Converts a physical address (PA) to a virtual address (VA). This routine
- // Uses the oemaddresstable defined in the platform.
- //
- Void * oalpatova (uint 32 Pa, bool cached)
- {
- Oal_address_table * ptable = g_oaladdresstable;
- Void * Va = NULL;
- Oalmsg (oal_memory & oal_func, (L "+ oalpatova (0x % x, % d) \ r \ n", Pa, cached ));
- // Search the table for address range
- While (ptable-> size! = 0 ){
- If (
- Pa> = ptable-> PA &&
- Pa <= (ptable-> pa + (ptable-> size <20)-1)
- ) Break; // match found to find similar memory in the table
- Ptable ++;
- }
- // If address table entry is valid compute the VA
- If (ptable-> size! = 0 ){
- Va = (void *) (ptable-> Ca + (Pa-ptable-> Pa ));
- // If VA is Uncached, set the Uncached bit
- If (! Cached) (uint32) va | = oal_memory_cache_bit;
- }
- // Indicate the virtual address
- Oalmsg (oal_memory & oal_func, (L "-oalpatova (Va = 0x % 08x) \ r \ n", VA ));
- Return Va;
- }
- //------------------------------------------------------------------------------
- //
- // Function: oalvatopa
- //
- // Converts a virtual address (VA) to a physical address (Pa). This routine
- // Uses the oemaddresstable defined in the platform.
- //
- Uint32 oalvatopa (void * PVA)
- {
- Oal_address_table * ptable = g_oaladdresstable;
- Uint32 Va = (uint32) PVA;
- Udint 32 Pa = 0;
- Oalmsg (oal_memory & oal_func, (L "+ oalvatopa (0x % 08x) \ r \ n", PVA ));
- // Virtual address must be in cached or Uncached regions. Virtual Memory range
- If (va <0x80000000 | va> = 0xc0000000 ){
- Oalmsg (oal_error ,(
- L "error: oalvatopa: Invalid virtual address 0x % 08x \ r \ n", PVA
- ));
- Goto cleanup;
- }
- // Address must be cached, as entries in oemaddresstable are cached address.
- Va = va &~ Oal_memory_cache_bit;
- // Search the table for address range
- While (ptable-> size! = 0 ){
- If (va> = ptable-> Ca & va <= ptable-> Ca + (ptable-> size <20)-1 ){
- Break;
- }
- Ptable ++;
- }
- // If address table entry is valid compute the PA
- If (ptable-> size! = 0) pA = ptable-> pa + va-ptable-> Ca;
- Cleanup:
- // Indicate physical address
- Oalmsg (oal_memory & oal_func, (L "-oalvatopa (Pa = 0x % x) \ r \ n", PA ));
- Return Pa;
- }
- //------------------------------------------------------------------------------
- // From the two functions, we can see that this table is only for ease of modification. In fact, manual access to virtual memory is also possible.
- . As for the access to gpio, I will leave it for a moment. Good luck has gained a lot today.
Reprinted Please note: the author wogoyixikexie @ gliet. Guilin University of electronic science and technology, a Department of Science and Technology Association. If any error occurs, you can leave a message to indicate it.