io.h 1.8 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. void *phys_to_virt(phys_addr_t paddr);
  9. #define phys_to_virt phys_to_virt
  10. phys_addr_t virt_to_phys(void *vaddr);
  11. #define virt_to_phys virt_to_phys
  12. void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
  13. #define map_physmem map_physmem
  14. /*
  15. * Take down a mapping set up by map_physmem().
  16. */
  17. void unmap_physmem(const void *vaddr, unsigned long flags);
  18. #define unmap_physmem unmap_physmem
  19. #include <asm-generic/io.h>
  20. /* For sandbox, we want addresses to point into our RAM buffer */
  21. static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
  22. {
  23. return map_physmem(paddr, len, MAP_WRBACK);
  24. }
  25. /* Remove a previous mapping */
  26. static inline void unmap_sysmem(const void *vaddr)
  27. {
  28. unmap_physmem(vaddr, MAP_WRBACK);
  29. }
  30. /* Map from a pointer to our RAM buffer */
  31. phys_addr_t map_to_sysmem(const void *ptr);
  32. /* Define nops for sandbox I/O access */
  33. #define readb(addr) ((void)addr, 0)
  34. #define readw(addr) ((void)addr, 0)
  35. #define readl(addr) ((void)addr, 0)
  36. #define writeb(v, addr) ((void)addr)
  37. #define writew(v, addr) ((void)addr)
  38. #define writel(v, addr) ((void)addr)
  39. /* I/O access functions */
  40. int inl(unsigned int addr);
  41. int inw(unsigned int addr);
  42. int inb(unsigned int addr);
  43. void outl(unsigned int value, unsigned int addr);
  44. void outw(unsigned int value, unsigned int addr);
  45. void outb(unsigned int value, unsigned int addr);
  46. static inline void _insw(volatile u16 *port, void *buf, int ns)
  47. {
  48. }
  49. static inline void _outsw(volatile u16 *port, const void *buf, int ns)
  50. {
  51. }
  52. #define insw(port, buf, ns) _insw((u16 *)port, buf, ns)
  53. #define outsw(port, buf, ns) _outsw((u16 *)port, buf, ns)
  54. /* For systemace.c */
  55. #define out16(addr, val)
  56. #define in16(addr) 0
  57. #include <iotrace.h>
  58. #include <asm/types.h>
  59. #endif