Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals  

IxOsServicesMemMap.h

Go to the documentation of this file.
00001 
00048 #ifndef IxOsServicesMemMap_H
00049 #define IxOsServicesMemMap_H
00050 
00051 #include <ixp425.h>
00052 #include <IxTypes.h>
00053 #include <IxOsServicesMemAccess.h>
00054  
00060 /* map sizes to be used when requesting memory with IX_OS_SERV_MEM_MAP */
00061 
00062 #define IX_OSSERV_QMGR_MAP_SIZE           (0x4000)     
00063 #define IX_OSSERV_EXP_REG_MAP_SIZE        (0x1000)     
00064 #define IX_OSSERV_UART1_MAP_SIZE          (0x1000)     
00065 #define IX_OSSERV_UART2_MAP_SIZE          (0x1000)     
00066 #define IX_OSSERV_PMU_MAP_SIZE            (0x1000)     
00067 #define IX_OSSERV_OSTS_MAP_SIZE            (0x1000)    
00068 #define IX_OSSERV_NPEA_MAP_SIZE           (0x1000)     
00069 #define IX_OSSERV_NPEB_MAP_SIZE           (0x1000)     
00070 #define IX_OSSERV_NPEC_MAP_SIZE           (0x1000)     
00071 #define IX_OSSERV_ETHA_MAP_SIZE           (0x1000)     
00072 #define IX_OSSERV_ETHB_MAP_SIZE           (0x1000)     
00073 #define IX_OSSERV_USB_MAP_SIZE            (0x1000)     
00074 #define IX_OSSERV_GPIO_MAP_SIZE           (0x1000)     
00075 #define IX_OSSERV_EXP_BUS_MAP_SIZE        (0x08000000) 
00076 #define IX_OSSERV_EXP_BUS_CS1_MAP_SIZE    (0x01000000) 
00077 #define IX_OSSERV_EXP_BUS_CS4_MAP_SIZE    (0x01000000) 
00079 /* physical addresses to be used when requesting
00080    memory with IX_OS_SERV_MEM_MAP */
00081 #ifdef IX_OSSERV_LINUX_BE
00082 
00083 #define IX_OSSERV_GPIO_PHYS_BASE           IXP425_GPIO_BASE_PHYS
00084 #define IX_OSSERV_UART1_PHYS_BASE          IXP425_UART1_BASE_PHYS
00085 #define IX_OSSERV_UART2_PHYS_BASE          IXP425_UART2_BASE_PHYS
00086 #define IX_OSSERV_ETHA_PHYS_BASE           IXP425_EthA_BASE_PHYS
00087 #define IX_OSSERV_ETHB_PHYS_BASE           IXP425_EthB_BASE_PHYS
00088 #define IX_OSSERV_NPEA_PHYS_BASE           IXP425_NPEA_BASE_PHYS
00089 #define IX_OSSERV_NPEB_PHYS_BASE           IXP425_NPEB_BASE_PHYS
00090 #define IX_OSSERV_NPEC_PHYS_BASE           IXP425_NPEC_BASE_PHYS
00091 #define IX_OSSERV_PERIPHERAL_PHYS_BASE     IXP425_PERIPHERAL_BASE_PHYS
00092 #define IX_OSSERV_QMGR_PHYS_BASE           IXP425_QMGR_BASE_PHYS
00093 #define IX_OSSERV_OSTS_PHYS_BASE           IXP425_TIMER_BASE_PHYS
00094 #define IX_OSSERV_USB_PHYS_BASE            IXP425_USB_BASE_PHYS
00095 #define IX_OSSERV_EXP_BUS_PHYS_BASE        IXP425_EXP_BUS_BASE2_PHYS
00096 #define IX_OSSERV_EXP_BUS_BOOT_PHYS_BASE   IXP425_EXP_BUS_BASE1_PHYS
00097 #define IX_OSSERV_EXP_BUS_CS1_PHYS_BASE    IXP425_EXP_BUS_CS1_BASE_PHYS
00098 #define IX_OSSERV_EXP_BUS_CS4_PHYS_BASE    IXP425_EXP_BUS_CS4_BASE_PHYS
00099 #define IX_OSSERV_EXP_BUS_REGS_PHYS_BASE   IXP425_EXP_CFG_BASE_PHYS
00100 
00101 #elif defined (IX_OSSERV_VXWORKS_LE) || defined (IX_OSSERV_VXWORKS_BE)
00102 
00103 #define IX_OSSERV_GPIO_PHYS_BASE           IXP425_GPIO_BASE
00104 #define IX_OSSERV_UART1_PHYS_BASE          IXP425_UART1_BASE
00105 #define IX_OSSERV_UART2_PHYS_BASE          IXP425_UART2_BASE
00106 #define IX_OSSERV_ETHA_PHYS_BASE           IXP425_EthA_BASE
00107 #define IX_OSSERV_ETHB_PHYS_BASE           IXP425_EthB_BASE
00108 #define IX_OSSERV_NPEA_PHYS_BASE           IXP425_NPEA_BASE
00109 #define IX_OSSERV_NPEB_PHYS_BASE           IXP425_NPEB_BASE
00110 #define IX_OSSERV_NPEC_PHYS_BASE           IXP425_NPEC_BASE
00111 #define IX_OSSERV_PERIPHERAL_PHYS_BASE     IXP425_PERIPHERAL_BASE
00112 #define IX_OSSERV_QMGR_PHYS_BASE           IXP425_QMGR_BASE
00113 #define IX_OSSERV_OSTS_PHYS_BASE           IXP425_OSTS
00114 #define IX_OSSERV_USB_PHYS_BASE            IXP425_USB_BASE
00115 #define IX_OSSERV_EXP_BUS_PHYS_BASE        IXP425_EXPANSION_BUS_BASE2
00116 #define IX_OSSERV_EXP_BUS_BOOT_PHYS_BASE   IXP425_EXPANSION_BUS_BASE1
00117 #define IX_OSSERV_EXP_BUS_CS1_PHYS_BASE    IXP425_EXPANSION_BUS_CS1_BASE
00118 #define IX_OSSERV_EXP_BUS_CS4_PHYS_BASE    IXP425_EXPANSION_BUS_CS4_BASE
00119 #define IX_OSSERV_EXP_BUS_REGS_PHYS_BASE   IXP425_EXP_CONFIG_BASE
00120 
00121 #else
00122 
00123 #error This operating system is not supported - only VxWorks and Linux are supported.
00124 
00125 #endif
00126 
00127 /* @} */
00128 
00129 typedef enum
00130 {
00131   IX_STATIC_MAP = 0, 
00132   IX_DYNAMIC_MAP 
00133 } IxOsServMapEntryType;
00134 
00135 typedef enum
00136 {
00137   IX_BE_MAP    = 0x1, 
00138   IX_LE_AC_MAP = 0x2, 
00139   IX_LE_DC_MAP = 0x4  
00140 } IxOsServMapCoherencyType;
00141 
00142 /* determine coherency type required for the component 
00143    including this file */
00144 #if defined (CSR_BE_MAPPING)
00145   
00146 #define IX_COMPONENT_COHERENCY (IX_BE_MAP)
00147   
00148 #elif defined (CSR_LE_ADDRESS_COHERENT_MAPPING)
00149 
00150 #define IX_COMPONENT_COHERENCY (IX_LE_AC_MAP)
00151 
00152 #elif defined (CSR_LE_DATA_COHERENT_MAPPING)
00153 
00154 #define IX_COMPONENT_COHERENCY (IX_LE_DC_MAP)
00155 
00156 #else
00157 
00158 #error This component does not define a usable coherency mode in \
00159 IxOsServicesComponents.h. Either define the coherency or do not \
00160 include this file.
00161 
00162 #endif
00163 
00164 /* prototypes */
00165 PUBLIC void *
00166 ixOsServMemMap(UINT32 physicalAddress, UINT32 size, UINT32 coherency);
00167 
00168 PUBLIC void
00169 ixOsServMemUnmap(UINT32 virtualAddress, UINT32 coherency);
00170 
00171 PUBLIC UINT32
00172 ixOsServMemVirtToPhys(UINT32 virtualAddress, UINT32 coherency);
00173 
00209 #define IX_OSSERV_MEM_MAP(requestedPhysicalAddress, size) \
00210   ixOsServMemMap(requestedPhysicalAddress, size, IX_COMPONENT_COHERENCY)
00211 
00231 #define IX_OSSERV_MEM_UNMAP(requestedVirtualAddress) \
00232   ixOsServMemUnmap(requestedVirtualAddress, IX_COMPONENT_COHERENCY)
00233   
00247 #define IX_OSSERV_MMAP_VIRT_TO_PHYS_TRANSLATION(virtualAddress) \
00248   ixOsServMemVirtToPhys(virtualAddress, IX_COMPONENT_COHERENCY)
00249 
00250 typedef struct _IxOsServMemoryMap
00251 {
00252   /* map type - IX_STATIC_MAP or IX_DYNAMIC_MAP;
00253      dynamic maps are allocated by the OS, static maps are only simulated
00254      by this component for portability */
00255   IxOsServMapEntryType type;
00256      
00257   /* physical address of the memory mapped I/O zone 
00258      - initialized in the global memory map */
00259   UINT32 physicalAddress;
00260   
00261   /* size of map - initialized in the global memory map */
00262   UINT32 size;
00263   
00264   /* virtual address of the zone; must be predefined in 
00265      the global memory map for static maps and has to be NULL 
00266      for dynamic maps (populated on allocation) */
00267   UINT32 virtualAddress;
00268   
00269   /* pointer to a map function called to map a dynamic map; 
00270      will populate the virtualAddress field */
00271   void (*mapFunction)(struct _IxOsServMemoryMap *map);
00272     
00273   /* pointer to a map function called to unmap a dynamic map; 
00274      will reset the virtualAddress field to NULL */
00275   void (*unmapFunction)(struct _IxOsServMemoryMap *map);
00276   
00277   /* reference count describing how many components share this map; 
00278      actual allocation/deallocation for dynamic maps is done only 
00279      between 0 <=> 1 transitions of the counter */
00280   UINT32 refCount;
00281      
00282   /* memory coherency for the map; can be a combination of IX_BE_MAP (Big 
00283      Endian) and IX_LE_AC_MAP or IX_LE_DC_MAP (Little Endian, Address
00284      Coherent or Data Coherent). Any combination is allowed provided it
00285      contains at most one LE flag - e.g. (IX_BE_MAP), (IX_LE_AC_MAP),
00286      (IX_BE_MAP | IX_LE_DC_MAP) are valid combinations while
00287      (IX_BE_MAP | IX_LE_DC_MAP | IX_LE_AC_MAP) is not. */
00288   IxOsServMapCoherencyType coherency;
00289      
00290   /* user-friendly name */
00291   char *name;
00292 } IxOsServMemoryMap;
00293   
00294 #if defined (__linux)
00295 
00296 /* Linux-specific map/unmap functions to be used with dynamic maps */
00297 #include <asm/io.h>
00298 #include <linux/ioport.h>
00299 void ixOsServLinuxMemMap(IxOsServMemoryMap *map);
00300 void ixOsServLinuxMemUnmap(IxOsServMemoryMap *map);
00301 
00302 /* prototypes for linux map/unmap functions */
00303 PUBLIC void 
00304 ixOsServLinuxMemMap(IxOsServMemoryMap *map);
00305 
00306 PUBLIC void 
00307 ixOsServLinuxMemUnmap(IxOsServMemoryMap *map);
00308 
00309 #endif
00310 
00311 #ifdef IxOsServicesMem_C
00312 
00313 #if defined (__linux)
00314 
00315 /* Note: - dynamic maps will be mapped using ioremap() with the base addresses and sizes declared in this array (matched to include the requested zones, 
00316            but not using the actual ixOsServMemMap requests) 
00317          - static maps have to be also declared in arch/arm/mach-ixp425/mm.c using the exact same addresses and size
00318          - the user-friendly name will be made available in /proc for dynamically allocated maps 
00319          - the declared order of the maps is important if the maps overlap - when a common zone is requested only the
00320            first usable map will be always chosen */
00321 IxOsServMemoryMap ixOsServGlobalMemoryMap[] = 
00322 {
00323   /* Queue Manager */
00324   { 
00325     IX_STATIC_MAP,                   /* type            */
00326     IXP425_QMGR_BASE_PHYS,           /* physicalAddress */
00327     IXP425_QMGR_REGION_SIZE,         /* size            */
00328     IXP425_QMGR_BASE_VIRT,           /* virtualAddress  */
00329     NULL,                            /* mapFunction     */
00330     NULL,                            /* unmapFunction   */
00331     0,                               /* refCount        */
00332     IX_BE_MAP,                       /* coherency       */
00333     "qMgr"                           /* name            */
00334   },
00335 
00336   /* APB Peripherals */
00337   { 
00338     IX_STATIC_MAP,                   /* type            */
00339     IXP425_PERIPHERAL_BASE_PHYS,     /* physicalAddress */
00340     IXP425_PERIPHERAL_REGION_SIZE,   /* size            */
00341     IXP425_PERIPHERAL_BASE_VIRT,     /* virtualAddress  */
00342     NULL,                            /* mapFunction     */
00343     NULL,                            /* unmapFunction   */
00344     0,                               /* refCount        */
00345     IX_BE_MAP,                       /* coherency       */
00346     "peripherals"                    /* name            */
00347   },
00348 
00349   /* Expansion Bus Config Registers */
00350   { 
00351     IX_STATIC_MAP,                   /* type            */
00352     IXP425_EXP_CFG_BASE_PHYS,        /* physicalAddress */
00353     IXP425_EXP_CFG_REGION_SIZE,      /* size            */
00354     IXP425_EXP_CFG_BASE_VIRT,        /* virtualAddress  */
00355     NULL,                            /* mapFunction     */
00356     NULL,                            /* unmapFunction   */
00357     0,                               /* refCount        */
00358     IX_BE_MAP,                       /* coherency       */
00359     "Exp Cfg"                        /* name            */
00360   },
00361   
00362   /* PCI config Registers */      
00363   {
00364     IX_STATIC_MAP,                   /* type            */
00365     IXP425_PCI_CFG_BASE_PHYS,        /* physicalAddress */
00366     IXP425_PCI_CFG_REGION_SIZE,      /* size            */
00367     IXP425_PCI_CFG_BASE_VIRT,        /* virtualAddress  */
00368     NULL,                            /* mapFunction     */
00369     NULL,                            /* unmapFunction   */
00370     0,                               /* refCount        */
00371     IX_BE_MAP,                       /* coherency       */
00372     "pciConfig"                      /* name            */
00373   },
00374         
00375   /* Expansion Bus */
00376   {
00377     IX_DYNAMIC_MAP,                  /* type            */
00378     IXP425_EXP_BUS_BASE_PHYS,        /* physicalAddress */
00379     IXP425_EXP_BUS_REGION_SIZE,      /* size            */
00380     0,                               /* virtualAddress  */
00381     ixOsServLinuxMemMap,             /* mapFunction     */
00382     ixOsServLinuxMemUnmap,           /* unmapFunction   */
00383     0,                               /* refCount        */
00384     IX_BE_MAP,                       /* coherency       */
00385     "Exp Bus"                        /* name            */
00386   }
00387 };
00388 
00389 #elif defined (__vxworks)
00390 
00391 /* In VxWorks there's a 1:1 mapping between the virtual address space and the 
00392    physical address space, therefore all requests for a zone will be satisfied
00393    with the very same pointer 
00394    (cookie = requestedAddress - physicalAddress + virtualAddress, 
00395    and physicalAddress == virtualAddress == 0x00000000)
00396    and the "global" map is obviously large enough (0xFFFFFFFF) to host any zone,
00397    therefore it will be matched against every request not overrunning 4Gb.
00398    Note: this is valid only for the default LE coherency mode (AC). Maps
00399    aliasing I/O memory at different addresses in DC mode require additional
00400    definition - for an example see the qMgr LE_DC alias */
00401 IxOsServMemoryMap ixOsServGlobalMemoryMap[] = 
00402 {
00403   /* Global BE and LE_AC map */
00404   { 
00405     IX_STATIC_MAP,                   /* type            */
00406     0x00000000,                      /* physicalAddress */
00407     0xFFFFFFFF,                      /* size            */
00408     0x00000000,                      /* virtualAddress  */
00409     NULL,                            /* mapFunction     */
00410     NULL,                            /* unmapFunction   */
00411     0,                               /* refCount        */
00412     IX_BE_MAP | IX_LE_AC_MAP,        /* coherency       */
00413     "global"                         /* name            */
00414   },
00415         
00416   /* QMgr LE_DC map */
00417   { 
00418     IX_STATIC_MAP,                   /* type            */
00419     IXP425_QMGR_BASE,                /* physicalAddress */
00420     IXP425_QMGR_SIZE,                /* size            */
00421     IXP425_QMGR_LE_DC_VIRT,          /* virtualAddress  */
00422     NULL,                            /* mapFunction     */
00423     NULL,                            /* unmapFunction   */
00424     0,                               /* refCount        */
00425     IX_LE_DC_MAP,                    /* coherency       */
00426     "qMgr LE_DC"                     /* name            */
00427   },
00428 
00429   /* Expansion Bus Config LE_DC map */
00430   {
00431       IX_STATIC_MAP,                 /* type            */
00432       IXP425_EXP_CONFIG_BASE,        /* physicalAddress */
00433       IXP425_EXP_CONFIG_SIZE,        /* size            */
00434       IXP425_EXP_CONFIG_LE_DC_VIRT,  /* virtualAddress  */
00435       NULL,                          /* mapFunction     */
00436       NULL,                          /* unmapFunction   */
00437       0,                             /* refCount        */
00438       IX_LE_DC_MAP,                  /* coherency       */
00439       "Exp Cfg LE_DC"                /* name            */
00440   },
00441         
00442   /* Peripherals LE_DC map */
00443   { 
00444     IX_STATIC_MAP,                   /* type            */
00445     IXP425_PERIPHERAL_BASE,          /* physicalAddress */
00446     IXP425_PERIPHERAL_SIZE,          /* size            */
00447     IXP425_PERIPHERAL_LE_DC_VIRT,    /* virtualAddress  */
00448     NULL,                            /* mapFunction     */
00449     NULL,                            /* unmapFunction   */
00450     0,                               /* refCount        */
00451     IX_LE_DC_MAP,                    /* coherency       */
00452     "peripherals LE_DC"              /* name            */
00453   }
00454 };
00455 
00456 #else
00457 
00458 #error This operating system is not supported - only VxWorks and Linux are supported.
00459 
00460 #endif
00461 
00462 #define IX_OSSERV_MEM_MAP_ELEMENTS (sizeof (ixOsServGlobalMemoryMap) / sizeof (IxOsServMemoryMap))
00463 
00464 #endif /* IxOsServicesMem.c visible definitions */
00465 
00466 #endif /* IxOsServicesMemMap_H */
Automatically generated from sources. © Intel Corp. 2003