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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *  linux/openpic.h -- OpenPIC definitions
  3.  *
  4.  *  Copyright (C) 1997 Geert Uytterhoeven
  5.  *
  6.  *  This file is based on the following documentation:
  7.  *
  8.  * The Open Programmable Interrupt Controller (PIC)
  9.  * Register Interface Specification Revision 1.2
  10.  *
  11.  * Issue Date: October 1995
  12.  *
  13.  * Issued jointly by Advanced Micro Devices and Cyrix Corporation
  14.  *
  15.  * AMD is a registered trademark of Advanced Micro Devices, Inc.
  16.  * Copyright (C) 1995, Advanced Micro Devices, Inc. and Cyrix, Inc.
  17.  * All Rights Reserved.
  18.  *
  19.  *  To receive a copy of this documentation, send an email to openpic@amd.com.
  20.  *
  21.  *  This file is subject to the terms and conditions of the GNU General Public
  22.  *  License.  See the file COPYING in the main directory of this archive
  23.  *  for more details.
  24.  */
  25. #ifndef _LINUX_OPENPIC_H
  26. #define _LINUX_OPENPIC_H
  27. #ifdef __KERNEL__
  28. #include <linux/config.h>
  29. /*
  30.  *  OpenPIC supports up to 2048 interrupt sources and up to 32 processors
  31.  */
  32. #define OPENPIC_MAX_SOURCES 2048
  33. #define OPENPIC_MAX_PROCESSORS 32
  34. #define OPENPIC_MAX_ISU 32
  35. #define OPENPIC_NUM_TIMERS 4
  36. #define OPENPIC_NUM_IPI 4
  37. #define OPENPIC_NUM_PRI 16
  38. #define OPENPIC_NUM_VECTORS OPENPIC_MAX_SOURCES
  39. /*
  40.  *  OpenPIC Registers are 32 bits and aligned on 128 bit boundaries
  41.  */
  42. typedef struct _OpenPIC_Reg {
  43. u_int Reg; /* Little endian! */
  44. char Pad[0xc];
  45. } OpenPIC_Reg;
  46. /*
  47.  *  Per Processor Registers
  48.  */
  49. typedef struct _OpenPIC_Processor {
  50. /*
  51.  *  Private Shadow Registers (for SLiC backwards compatibility)
  52.  */
  53. u_int IPI0_Dispatch_Shadow; /* Write Only */
  54. char Pad1[0x4];
  55. u_int IPI0_Vector_Priority_Shadow; /* Read/Write */
  56. char Pad2[0x34];
  57. /*
  58.  *  Interprocessor Interrupt Command Ports
  59.  */
  60. OpenPIC_Reg _IPI_Dispatch[OPENPIC_NUM_IPI]; /* Write Only */
  61. /*
  62.  *  Current Task Priority Register
  63.  */
  64. OpenPIC_Reg _Current_Task_Priority; /* Read/Write */
  65. char Pad3[0x10];
  66. /*
  67.  *  Interrupt Acknowledge Register
  68.  */
  69. OpenPIC_Reg _Interrupt_Acknowledge; /* Read Only */
  70. /*
  71.  *  End of Interrupt (EOI) Register
  72.  */
  73. OpenPIC_Reg _EOI; /* Read/Write */
  74. char Pad5[0xf40];
  75. } OpenPIC_Processor;
  76.     /*
  77.      *  Timer Registers
  78.      */
  79. typedef struct _OpenPIC_Timer {
  80. OpenPIC_Reg _Current_Count; /* Read Only */
  81. OpenPIC_Reg _Base_Count; /* Read/Write */
  82. OpenPIC_Reg _Vector_Priority; /* Read/Write */
  83. OpenPIC_Reg _Destination; /* Read/Write */
  84. } OpenPIC_Timer;
  85.     /*
  86.      *  Global Registers
  87.      */
  88. typedef struct _OpenPIC_Global {
  89. /*
  90.  *  Feature Reporting Registers
  91.  */
  92. OpenPIC_Reg _Feature_Reporting0; /* Read Only */
  93. OpenPIC_Reg _Feature_Reporting1; /* Future Expansion */
  94. /*
  95.  *  Global Configuration Registers
  96.  */
  97. OpenPIC_Reg _Global_Configuration0; /* Read/Write */
  98. OpenPIC_Reg _Global_Configuration1; /* Future Expansion */
  99. /*
  100.  *  Vendor Specific Registers
  101.  */
  102. OpenPIC_Reg _Vendor_Specific[4];
  103. /*
  104.  *  Vendor Identification Register
  105.  */
  106. OpenPIC_Reg _Vendor_Identification; /* Read Only */
  107. /*
  108.  *  Processor Initialization Register
  109.  */
  110. OpenPIC_Reg _Processor_Initialization; /* Read/Write */
  111. /*
  112.  *  IPI Vector/Priority Registers
  113.  */
  114. OpenPIC_Reg _IPI_Vector_Priority[OPENPIC_NUM_IPI]; /* Read/Write */
  115. /*
  116.  *  Spurious Vector Register
  117.  */
  118. OpenPIC_Reg _Spurious_Vector; /* Read/Write */
  119. /*
  120.  *  Global Timer Registers
  121.  */
  122. OpenPIC_Reg _Timer_Frequency; /* Read/Write */
  123. OpenPIC_Timer Timer[OPENPIC_NUM_TIMERS];
  124. char Pad1[0xee00];
  125. } OpenPIC_Global;
  126.     /*
  127.      *  Interrupt Source Registers
  128.      */
  129. typedef struct _OpenPIC_Source {
  130. OpenPIC_Reg _Vector_Priority; /* Read/Write */
  131. OpenPIC_Reg _Destination; /* Read/Write */
  132. } OpenPIC_Source, *OpenPIC_SourcePtr;
  133.     /*
  134.      *  OpenPIC Register Map
  135.      */
  136. struct OpenPIC {
  137. char Pad1[0x1000];
  138. /*
  139.  *  Global Registers
  140.  */
  141. OpenPIC_Global Global;
  142. /*
  143.  *  Interrupt Source Configuration Registers
  144.  */
  145. OpenPIC_Source Source[OPENPIC_MAX_SOURCES];
  146. /*
  147.  *  Per Processor Registers
  148.  */
  149. OpenPIC_Processor Processor[OPENPIC_MAX_PROCESSORS];
  150. };
  151. extern volatile struct OpenPIC *OpenPIC;
  152. /*
  153.  *  Current Task Priority Register
  154.  */
  155. #define OPENPIC_CURRENT_TASK_PRIORITY_MASK 0x0000000f
  156. /*
  157.  *  Who Am I Register
  158.  */
  159. #define OPENPIC_WHO_AM_I_ID_MASK 0x0000001f
  160. /*
  161.  *  Feature Reporting Register 0
  162.  */
  163. #define OPENPIC_FEATURE_LAST_SOURCE_MASK 0x07ff0000
  164. #define OPENPIC_FEATURE_LAST_SOURCE_SHIFT 16
  165. #define OPENPIC_FEATURE_LAST_PROCESSOR_MASK 0x00001f00
  166. #define OPENPIC_FEATURE_LAST_PROCESSOR_SHIFT 8
  167. #define OPENPIC_FEATURE_VERSION_MASK 0x000000ff
  168. /*
  169.  *  Global Configuration Register 0
  170.  */
  171. #define OPENPIC_CONFIG_RESET 0x80000000
  172. #define OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE 0x20000000
  173. #define OPENPIC_CONFIG_BASE_MASK 0x000fffff
  174. /*
  175.  *  Vendor Identification Register
  176.  */
  177. #define OPENPIC_VENDOR_ID_STEPPING_MASK 0x00ff0000
  178. #define OPENPIC_VENDOR_ID_STEPPING_SHIFT 16
  179. #define OPENPIC_VENDOR_ID_DEVICE_ID_MASK 0x0000ff00
  180. #define OPENPIC_VENDOR_ID_DEVICE_ID_SHIFT 8
  181. #define OPENPIC_VENDOR_ID_VENDOR_ID_MASK 0x000000ff
  182. /*
  183.  *  Vector/Priority Registers
  184.  */
  185. #define OPENPIC_MASK 0x80000000
  186. #define OPENPIC_ACTIVITY 0x40000000 /* Read Only */
  187. #define OPENPIC_PRIORITY_MASK 0x000f0000
  188. #define OPENPIC_PRIORITY_SHIFT 16
  189. #define OPENPIC_VECTOR_MASK 0x000007ff
  190. /*
  191.  *  Interrupt Source Registers
  192.  */
  193. #define OPENPIC_POLARITY_POSITIVE 0x00800000
  194. #define OPENPIC_POLARITY_NEGATIVE 0x00000000
  195. #define OPENPIC_POLARITY_MASK 0x00800000
  196. #define OPENPIC_SENSE_LEVEL 0x00400000
  197. #define OPENPIC_SENSE_EDGE 0x00000000
  198. #define OPENPIC_SENSE_MASK 0x00400000
  199. /*
  200.  *  Timer Registers
  201.  */
  202. #define OPENPIC_COUNT_MASK 0x7fffffff
  203. #define OPENPIC_TIMER_TOGGLE 0x80000000
  204. #define OPENPIC_TIMER_COUNT_INHIBIT 0x80000000
  205. /*
  206.  *  Aliases to make life simpler
  207.  */
  208. /* Per Processor Registers */
  209. #define IPI_Dispatch(i) _IPI_Dispatch[i].Reg
  210. #define Current_Task_Priority _Current_Task_Priority.Reg
  211. #define Interrupt_Acknowledge _Interrupt_Acknowledge.Reg
  212. #define EOI _EOI.Reg
  213. /* Global Registers */
  214. #define Feature_Reporting0 _Feature_Reporting0.Reg
  215. #define Feature_Reporting1 _Feature_Reporting1.Reg
  216. #define Global_Configuration0 _Global_Configuration0.Reg
  217. #define Global_Configuration1 _Global_Configuration1.Reg
  218. #define Vendor_Specific(i) _Vendor_Specific[i].Reg
  219. #define Vendor_Identification _Vendor_Identification.Reg
  220. #define Processor_Initialization _Processor_Initialization.Reg
  221. #define IPI_Vector_Priority(i) _IPI_Vector_Priority[i].Reg
  222. #define Spurious_Vector _Spurious_Vector.Reg
  223. #define Timer_Frequency _Timer_Frequency.Reg
  224. /* Timer Registers */
  225. #define Current_Count _Current_Count.Reg
  226. #define Base_Count _Base_Count.Reg
  227. #define Vector_Priority _Vector_Priority.Reg
  228. #define Destination _Destination.Reg
  229. /* Interrupt Source Registers */
  230. #define Vector_Priority _Vector_Priority.Reg
  231. #define Destination _Destination.Reg
  232. /*
  233.  *  Local (static) OpenPIC Operations
  234.  */
  235. /* Global Operations */
  236. static void openpic_reset(void);
  237. static void openpic_enable_8259_pass_through(void);
  238. static void openpic_disable_8259_pass_through(void);
  239. static u_int openpic_irq(void);
  240. static void openpic_eoi(void);
  241. static u_int openpic_get_priority(void);
  242. static void openpic_set_priority(u_int pri);
  243. static u_int openpic_get_spurious(void);
  244. static void openpic_set_spurious(u_int vector);
  245. #ifdef CONFIG_SMP
  246. /* Interprocessor Interrupts */
  247. static void openpic_initipi(u_int ipi, u_int pri, u_int vector);
  248. static void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs);
  249. #endif
  250. /* Timer Interrupts */
  251. static void openpic_inittimer(u_int timer, u_int pri, u_int vector);
  252. static void openpic_maptimer(u_int timer, u_int cpumask);
  253. /* Interrupt Sources */
  254. static void openpic_enable_irq(u_int irq);
  255. static void openpic_disable_irq(u_int irq);
  256. static void openpic_initirq(u_int irq, u_int pri, u_int vector, int polarity,
  257.     int is_level);
  258. static void openpic_mapirq(u_int irq, u_int cpumask);
  259. static void openpic_set_sense(u_int irq, int sense);
  260. #endif /* __KERNEL__ */
  261. #endif /* _LINUX_OPENPIC_H */