Overview   API Reference  

l4io_config_space.hpp

00001 #if !defined(__L4IO_CONFIG_SPACE_HPP__)
00002 #define __L4IO_CONFIG_SPACE_HPP__
00003 
00004 //
00005 // L4 includes
00006 //
00007 #include <l4/generic_io/libio.h>
00008 
00009 //
00010 // sanity check: do not include the compat header(s) in this file.
00011 //     we need to call the real functions.
00012 //
00013 #if defined(l4io_pci_readb_cfg) || defined(l4io_pci_writeb_cfg) ||      \
00014         defined(l4io_pci_readw_cfg) || defined(l4io_pci_writew_cfg) ||  \
00015         defined(l4io_pci_readl_cfg) || defined(l4io_pci_writel_cfg)
00016     #error someone included the compat header(s). fix this.
00017 #endif
00018 
00019 template <typename WordT>
00020 struct l4io_config_space
00021 {};
00022 
00023 template <>
00024 struct l4io_config_space<uint8_t>
00025 {
00026     static inline int read(const l4io_pdev_t handle, const int offset, uint8_t *value)
00027     {
00028         return l4io_pci_readb_cfg(handle, offset, value);
00029     }
00030 
00031     static inline int write(const l4io_pdev_t handle, const int offset, const uint8_t value)
00032     {
00033         return l4io_pci_writeb_cfg(handle, offset, value);
00034     }
00035 };
00036 
00037 template <>
00038 struct l4io_config_space<uint16_t>
00039 {
00040     static inline int read(const l4io_pdev_t handle, const int offset, uint16_t *value)
00041     {
00042         return l4io_pci_readw_cfg(handle, offset, value);
00043     }
00044 
00045     static inline int write(const l4io_pdev_t handle, const int offset, const uint16_t value)
00046     {
00047         return l4io_pci_writew_cfg(handle, offset, value);
00048     }
00049 };
00050 
00051 template <>
00052 struct l4io_config_space<uint32_t>
00053 {
00054     static inline int read(const l4io_pdev_t handle, const int offset, uint32_t *value)
00055     {
00056         return l4io_pci_readl_cfg(handle, offset, value);
00057     }
00058 
00059     static inline int write(const l4io_pdev_t handle, const int offset, const uint32_t value)
00060     {
00061         return l4io_pci_writel_cfg(handle, offset, value);
00062     }
00063 };
00064 
00065 #endif
00066 
00067 // ***** end of source ***** //
00068 
00069 

L4vmm Reference Manual, written by Mario Schwalbe  © 2006-2008