lib_hssubr.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Copyright (C) 2000, 2001 Broadcom Corporation
  3.  * Copyright (C) 2002 Ralf Baechle
  4.  *
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License
  7.  * as published by the Free Software Foundation; either version 2
  8.  * of the License, or (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  */
  19. #ifndef _LIB_HSSUBR_H
  20. #define _LIB_HSSUBR_H
  21. #include <linux/config.h>
  22. #include <asm/addrspace.h>
  23. typedef long hsaddr_t;
  24. #ifdef CONFIG_MIPS64
  25. static inline void hs_write8(hsaddr_t a, uint8_t b)
  26. {
  27. *(volatile uint8_t *) a = PHYS_TO_XKSEG_UNCACHED(b);
  28. }
  29. static inline void hs_write16(hsaddr_t a, uint16_t b)
  30. {
  31. *(volatile uint16_t *) a = PHYS_TO_XKSEG_UNCACHED(b);
  32. }
  33. static inline void hs_write32(hsaddr_t a, uint32_t b)
  34. {
  35. *(volatile uint32_t *) a = PHYS_TO_XKSEG_UNCACHED(b);
  36. }
  37. static inline void hs_write64(hsaddr_t a, uint64_t b)
  38. {
  39. *(volatile uint32_t *) a = PHYS_TO_XKSEG_UNCACHED(b);
  40. }
  41. static inline uint8_t hs_read8(hsaddr_t a)
  42. {
  43. return *(volatile uint8_t *) a;
  44. }
  45. static inline uint16_t hs_read16(hsaddr_t a)
  46. {
  47. return *(volatile uint16_t *) a;
  48. }
  49. static inline uint32_t hs_read32(hsaddr_t a)
  50. {
  51. return *(volatile uint32_t *) a;
  52. }
  53. static inline uint64_t hs_read64(hsaddr_t a)
  54. {
  55. return *(volatile uint64_t *) a;
  56. }
  57. #else /* just CONFIG_MIPS32 */
  58. extern void hs_write8(hsaddr_t a, uint8_t b);
  59. extern void hs_write16(hsaddr_t a, uint16_t b);
  60. extern void hs_write32(hsaddr_t a, uint32_t b);
  61. extern void hs_write64(hsaddr_t a, uint64_t b);
  62. extern uint8_t hs_read8(hsaddr_t a);
  63. extern uint16_t hs_read16(hsaddr_t a);
  64. extern uint32_t hs_read32(hsaddr_t a);
  65. extern uint64_t hs_read64(hsaddr_t a);
  66. #endif
  67. #endif /* _LIB_HSSUBR_H */