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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * ACPI PCI Hot Plug Controller Driver
  3.  *
  4.  * Copyright (c) 1995,2001 Compaq Computer Corporation
  5.  * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
  6.  * Copyright (c) 2001 IBM Corp.
  7.  * Copyright (c) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
  8.  * Copyright (c) 2002 Takayoshi Kochi (t-kouchi@cq.jp.nec.com)
  9.  * Copyright (c) 2002 NEC Corporation
  10.  *
  11.  * All rights reserved.
  12.  *
  13.  * This program is free software; you can redistribute it and/or modify
  14.  * it under the terms of the GNU General Public License as published by
  15.  * the Free Software Foundation; either version 2 of the License, or (at
  16.  * your option) any later version.
  17.  *
  18.  * This program is distributed in the hope that it will be useful, but
  19.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21.  * NON INFRINGEMENT.  See the GNU General Public License for more
  22.  * details.
  23.  *
  24.  * You should have received a copy of the GNU General Public License
  25.  * along with this program; if not, write to the Free Software
  26.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  *
  28.  * Send feedback to <gregkh@us.ibm.com>,
  29.  *     <h-aono@ap.jp.nec.com>,
  30.  *     <t-kouchi@cq.jp.nec.com>
  31.  *
  32.  */
  33. #ifndef _ACPIPHP_H
  34. #define _ACPIPHP_H
  35. #include "include/acpi.h"
  36. #include "pci_hotplug.h"
  37. #if ACPI_CA_VERSION < 0x20020201
  38. /* until we get a new version of the ACPI driver for both ia32 and ia64 ... */
  39. #define acpi_util_eval_error(h,p,s)
  40. static acpi_status
  41. acpi_evaluate_integer (
  42. acpi_handle handle,
  43. acpi_string pathname,
  44. acpi_object_list *arguments,
  45. unsigned long *data)
  46. {
  47. acpi_status status = AE_OK;
  48. acpi_object element;
  49. acpi_buffer buffer = {sizeof(acpi_object), &element};
  50. if (!data)
  51. return AE_BAD_PARAMETER;
  52. status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
  53. if (ACPI_FAILURE(status)) {
  54. acpi_util_eval_error(handle, pathname, status);
  55. return status;
  56. }
  57. if (element.type != ACPI_TYPE_INTEGER) {
  58. acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
  59. return AE_BAD_DATA;
  60. }
  61. *data = element.integer.value;
  62. return AE_OK;
  63. }
  64. #else  /* ACPI_CA_VERSION < 0x20020201 */
  65. #include "acpi_bus.h"
  66. #endif
  67. /* compatibility stuff for ACPI CA */
  68. #ifndef ACPI_MEMORY_RANGE
  69. #define ACPI_MEMORY_RANGE MEMORY_RANGE
  70. #endif
  71. #ifndef ACPI_IO_RANGE
  72. #define ACPI_IO_RANGE IO_RANGE
  73. #endif
  74. #ifndef ACPI_BUS_NUMBER_RANGE
  75. #define ACPI_BUS_NUMBER_RANGE BUS_NUMBER_RANGE
  76. #endif
  77. #ifndef ACPI_PREFETCHABLE_MEMORY
  78. #define ACPI_PREFETCHABLE_MEMORY PREFETCHABLE_MEMORY
  79. #endif
  80. #ifndef ACPI_PRODUCER
  81. #define ACPI_PRODUCER PRODUCER
  82. #endif
  83. #define dbg(format, arg...)
  84. do {
  85. if (debug)
  86. printk (KERN_DEBUG "%s: " format "n",
  87. MY_NAME , ## arg); 
  88. } while (0)
  89. #define err(format, arg...) printk (KERN_ERR "%s: " format "n", MY_NAME , ## arg)
  90. #define info(format, arg...) printk (KERN_INFO "%s: " format "n", MY_NAME , ## arg)
  91. #define warn(format, arg...) printk (KERN_WARNING "%s: " format "n", MY_NAME , ## arg)
  92. #define SLOT_MAGIC 0x67267322
  93. /* name size which is used for entries in pcihpfs */
  94. #define SLOT_NAME_SIZE 16 /* ACPIxxxx */
  95. struct acpiphp_bridge;
  96. struct acpiphp_slot;
  97. struct pci_resource;
  98. /*
  99.  * struct slot - slot information for each *physical* slot
  100.  */
  101. struct slot {
  102. u32 magic;
  103. u8 number;
  104. struct hotplug_slot *hotplug_slot;
  105. struct list_head slot_list;
  106. /* if there are multiple corresponding ACPI slot objects,
  107.    this points to one of them */
  108. struct acpiphp_slot *acpi_slot;
  109. };
  110. /*
  111.  * struct pci_resource - describes pci resource (mem, pfmem, io, bus)
  112.  */
  113. struct pci_resource {
  114. struct pci_resource * next;
  115. u64 base;
  116. u32 length;
  117. };
  118. /**
  119.  * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
  120.  * @cache_line_size in DWORD
  121.  * @latency_timer in PCI clock
  122.  * @enable_SERR 0 or 1
  123.  * @enable_PERR 0 or 1
  124.  */
  125. struct hpp_param {
  126. u8 cache_line_size;
  127. u8 latency_timer;
  128. u8 enable_SERR;
  129. u8 enable_PERR;
  130. };
  131. /**
  132.  * struct acpiphp_bridge - PCI bridge information
  133.  *
  134.  * for each bridge device in ACPI namespace
  135.  */
  136. struct acpiphp_bridge {
  137. struct list_head list;
  138. acpi_handle handle;
  139. struct acpiphp_slot *slots;
  140. int type;
  141. int nr_slots;
  142. u8 seg;
  143. u8 bus;
  144. u8 sub;
  145. u32 flags;
  146. /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
  147. struct pci_bus *pci_bus;
  148. /* PCI-to-PCI bridge device */
  149. struct pci_dev *pci_dev;
  150. struct pci_ops *pci_ops;
  151. /* ACPI 2.0 _HPP parameters */
  152. struct hpp_param hpp;
  153. spinlock_t res_lock;
  154. /* available resources on this bus */
  155. struct pci_resource *mem_head;
  156. struct pci_resource *p_mem_head;
  157. struct pci_resource *io_head;
  158. struct pci_resource *bus_head;
  159. };
  160. /**
  161.  * struct acpiphp_slot - PCI slot information
  162.  *
  163.  * PCI slot information for each *physical* PCI slot
  164.  */
  165. struct acpiphp_slot {
  166. struct acpiphp_slot *next;
  167. struct acpiphp_bridge *bridge; /* parent */
  168. struct list_head funcs; /* one slot may have different
  169.    objects (i.e. for each function) */
  170. struct acpiphp_func *func; /* functions */
  171. struct semaphore crit_sect;
  172. u32 id; /* slot id (serial #) for hotplug core */
  173. u8 device; /* pci device# */
  174. u32 sun; /* ACPI _SUN (slot unique number) */
  175. u32 slotno; /* slot number relative to bridge */
  176. u32 flags; /* see below */
  177. };
  178. /**
  179.  * struct acpiphp_func - PCI slot information
  180.  *
  181.  * PCI function information for each object in ACPI namespace
  182.  * typically 8 objects per slot (i.e. for each PCI function)
  183.  */
  184. struct acpiphp_func {
  185. struct acpiphp_slot *slot; /* parent */
  186. struct list_head sibling;
  187. struct pci_dev *pci_dev;
  188. acpi_handle handle;
  189. u8 function; /* pci function# */
  190. u32 flags; /* see below */
  191. /* resources used for this function */
  192. struct pci_resource *mem_head;
  193. struct pci_resource *p_mem_head;
  194. struct pci_resource *io_head;
  195. struct pci_resource *bus_head;
  196. };
  197. /* PCI bus bridge HID */
  198. #define ACPI_PCI_HOST_HID "PNP0A03"
  199. /* PCI BRIDGE type */
  200. #define BRIDGE_TYPE_HOST 0
  201. #define BRIDGE_TYPE_P2P 1
  202. /* ACPI _STA method value (ignore bit 4; battery present) */
  203. #define ACPI_STA_PRESENT (0x00000001)
  204. #define ACPI_STA_ENABLED (0x00000002)
  205. #define ACPI_STA_SHOW_IN_UI (0x00000004)
  206. #define ACPI_STA_FUNCTIONING (0x00000008)
  207. #define ACPI_STA_ALL (0x0000000f)
  208. /* bridge flags */
  209. #define BRIDGE_HAS_STA (0x00000001)
  210. #define BRIDGE_HAS_EJ0 (0x00000002)
  211. #define BRIDGE_HAS_HPP (0x00000004)
  212. #define BRIDGE_HAS_PS0 (0x00000010)
  213. #define BRIDGE_HAS_PS1 (0x00000020)
  214. #define BRIDGE_HAS_PS2 (0x00000040)
  215. #define BRIDGE_HAS_PS3 (0x00000080)
  216. /* slot flags */
  217. #define SLOT_POWEREDON (0x00000001)
  218. #define SLOT_ENABLED (0x00000002)
  219. #define SLOT_MULTIFUNCTION (x000000004)
  220. /* function flags */
  221. #define FUNC_HAS_STA (0x00000001)
  222. #define FUNC_HAS_EJ0 (0x00000002)
  223. #define FUNC_HAS_PS0 (0x00000010)
  224. #define FUNC_HAS_PS1 (0x00000020)
  225. #define FUNC_HAS_PS2 (0x00000040)
  226. #define FUNC_HAS_PS3 (0x00000080)
  227. /* not yet */
  228. #define SLOT_SUPPORT_66MHZ (0x00010000)
  229. #define SLOT_SUPPORT_100MHZ (0x00020000)
  230. #define SLOT_SUPPORT_133MHZ (0x00040000)
  231. #define SLOT_SUPPORT_PCIX (0x00080000)
  232. /* function prototypes */
  233. /* acpiphp_glue.c */
  234. extern int acpiphp_glue_init (void);
  235. extern void acpiphp_glue_exit (void);
  236. extern int acpiphp_get_num_slots (void);
  237. extern struct acpiphp_slot *get_slot_from_id (int id);
  238. typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
  239. extern int acpiphp_for_each_slot (acpiphp_callback fn, void *data);
  240. extern int acpiphp_check_bridge (struct acpiphp_bridge *bridge);
  241. extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
  242. extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
  243. extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
  244. extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
  245. extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
  246. extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
  247. /* acpiphp_pci.c */
  248. extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
  249. extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
  250. extern int acpiphp_configure_function (struct acpiphp_func *func);
  251. extern int acpiphp_unconfigure_function (struct acpiphp_func *func);
  252. extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
  253. extern int acpiphp_init_func_resource (struct acpiphp_func *func);
  254. /* acpiphp_res.c */
  255. extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size);
  256. extern struct pci_resource *acpiphp_get_max_resource (struct pci_resource **head, u32 size);
  257. extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size);
  258. extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size);
  259. extern int acpiphp_resource_sort_and_combine (struct pci_resource **head);
  260. extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length);
  261. extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to);
  262. extern void acpiphp_free_resource (struct pci_resource **res);
  263. extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge); /* debug */
  264. extern void acpiphp_dump_func_resource (struct acpiphp_func *func); /* debug */
  265. #endif /* _ACPIPHP_H */