io.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __SANDBOX_ASM_IO_H
  7. #define __SANDBOX_ASM_IO_H
  8. /*
  9. * Given a physical address and a length, return a virtual address
  10. * that can be used to access the memory range with the caching
  11. * properties specified by "flags".
  12. */
  13. #define MAP_NOCACHE (0)
  14. #define MAP_WRCOMBINE (0)
  15. #define MAP_WRBACK (0)
  16. #define MAP_WRTHROUGH (0)
  17. void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
  18. /*
  19. * Take down a mapping set up by map_physmem().
  20. */
  21. void unmap_physmem(const void *vaddr, unsigned long flags);
  22. /* For sandbox, we want addresses to point into our RAM buffer */
  23. static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
  24. {
  25. return map_physmem(paddr, len, MAP_WRBACK);
  26. }
  27. /* Remove a previous mapping */
  28. static inline void unmap_sysmem(const void *vaddr)
  29. {
  30. unmap_physmem(vaddr, MAP_WRBACK);
  31. }
  32. /* Map from a pointer to our RAM buffer */
  33. phys_addr_t map_to_sysmem(const void *ptr);
  34. /* Define nops for sandbox I/O access */
  35. #define readb(addr) ((void)addr, 0)
  36. #define readw(addr) ((void)addr, 0)
  37. #define readl(addr) ((void)addr, 0)
  38. #define writeb(v, addr) ((void)addr)
  39. #define writew(v, addr) ((void)addr)
  40. #define writel(v, addr) ((void)addr)
  41. /* I/O access functions */
  42. int inl(unsigned int addr);
  43. int inw(unsigned int addr);
  44. int inb(unsigned int addr);
  45. void outl(unsigned int value, unsigned int addr);
  46. void outw(unsigned int value, unsigned int addr);
  47. void outb(unsigned int value, unsigned int addr);
  48. static inline void _insw(volatile u16 *port, void *buf, int ns)
  49. {
  50. }
  51. static inline void _outsw(volatile u16 *port, const void *buf, int ns)
  52. {
  53. }
  54. #define insw(port, buf, ns) _insw((u16 *)port, buf, ns)
  55. #define outsw(port, buf, ns) _outsw((u16 *)port, buf, ns)
  56. /* For systemace.c */
  57. #define out16(addr, val)
  58. #define in16(addr) 0
  59. #include <iotrace.h>
  60. #include <asm/types.h>
  61. #endif