osl.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382
  1. /*
  2. * acpi_osl.c - OS-dependent functions ($Revision: 83 $)
  3. *
  4. * Copyright (C) 2000 Andrew Henroid
  5. * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  6. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  7. * Copyright (c) 2008 Intel Corporation
  8. * Author: Matthew Wilcox <willy@linux.intel.com>
  9. *
  10. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. *
  26. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. *
  28. */
  29. #include <linux/module.h>
  30. #include <linux/kernel.h>
  31. #include <linux/slab.h>
  32. #include <linux/mm.h>
  33. #include <linux/pci.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/kmod.h>
  36. #include <linux/delay.h>
  37. #include <linux/workqueue.h>
  38. #include <linux/nmi.h>
  39. #include <linux/acpi.h>
  40. #include <linux/efi.h>
  41. #include <linux/ioport.h>
  42. #include <linux/list.h>
  43. #include <linux/jiffies.h>
  44. #include <linux/semaphore.h>
  45. #include <asm/io.h>
  46. #include <asm/uaccess.h>
  47. #include <acpi/acpi.h>
  48. #include <acpi/acpi_bus.h>
  49. #include <acpi/processor.h>
  50. #define _COMPONENT ACPI_OS_SERVICES
  51. ACPI_MODULE_NAME("osl");
  52. #define PREFIX "ACPI: "
  53. struct acpi_os_dpc {
  54. acpi_osd_exec_callback function;
  55. void *context;
  56. struct work_struct work;
  57. };
  58. #ifdef CONFIG_ACPI_CUSTOM_DSDT
  59. #include CONFIG_ACPI_CUSTOM_DSDT_FILE
  60. #endif
  61. #ifdef ENABLE_DEBUGGER
  62. #include <linux/kdb.h>
  63. /* stuff for debugger support */
  64. int acpi_in_debugger;
  65. EXPORT_SYMBOL(acpi_in_debugger);
  66. extern char line_buf[80];
  67. #endif /*ENABLE_DEBUGGER */
  68. static unsigned int acpi_irq_irq;
  69. static acpi_osd_handler acpi_irq_handler;
  70. static void *acpi_irq_context;
  71. static struct workqueue_struct *kacpid_wq;
  72. static struct workqueue_struct *kacpi_notify_wq;
  73. struct acpi_res_list {
  74. resource_size_t start;
  75. resource_size_t end;
  76. acpi_adr_space_type resource_type; /* IO port, System memory, ...*/
  77. char name[5]; /* only can have a length of 4 chars, make use of this
  78. one instead of res->name, no need to kalloc then */
  79. struct list_head resource_list;
  80. };
  81. static LIST_HEAD(resource_list_head);
  82. static DEFINE_SPINLOCK(acpi_res_lock);
  83. #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */
  84. static char osi_additional_string[OSI_STRING_LENGTH_MAX];
  85. /*
  86. * The story of _OSI(Linux)
  87. *
  88. * From pre-history through Linux-2.6.22,
  89. * Linux responded TRUE upon a BIOS OSI(Linux) query.
  90. *
  91. * Unfortunately, reference BIOS writers got wind of this
  92. * and put OSI(Linux) in their example code, quickly exposing
  93. * this string as ill-conceived and opening the door to
  94. * an un-bounded number of BIOS incompatibilities.
  95. *
  96. * For example, OSI(Linux) was used on resume to re-POST a
  97. * video card on one system, because Linux at that time
  98. * could not do a speedy restore in its native driver.
  99. * But then upon gaining quick native restore capability,
  100. * Linux has no way to tell the BIOS to skip the time-consuming
  101. * POST -- putting Linux at a permanent performance disadvantage.
  102. * On another system, the BIOS writer used OSI(Linux)
  103. * to infer native OS support for IPMI! On other systems,
  104. * OSI(Linux) simply got in the way of Linux claiming to
  105. * be compatible with other operating systems, exposing
  106. * BIOS issues such as skipped device initialization.
  107. *
  108. * So "Linux" turned out to be a really poor chose of
  109. * OSI string, and from Linux-2.6.23 onward we respond FALSE.
  110. *
  111. * BIOS writers should NOT query _OSI(Linux) on future systems.
  112. * Linux will complain on the console when it sees it, and return FALSE.
  113. * To get Linux to return TRUE for your system will require
  114. * a kernel source update to add a DMI entry,
  115. * or boot with "acpi_osi=Linux"
  116. */
  117. static struct osi_linux {
  118. unsigned int enable:1;
  119. unsigned int dmi:1;
  120. unsigned int cmdline:1;
  121. unsigned int known:1;
  122. } osi_linux = { 0, 0, 0, 0};
  123. static void __init acpi_request_region (struct acpi_generic_address *addr,
  124. unsigned int length, char *desc)
  125. {
  126. struct resource *res;
  127. if (!addr->address || !length)
  128. return;
  129. if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
  130. res = request_region(addr->address, length, desc);
  131. else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
  132. res = request_mem_region(addr->address, length, desc);
  133. }
  134. static int __init acpi_reserve_resources(void)
  135. {
  136. acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length,
  137. "ACPI PM1a_EVT_BLK");
  138. acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length,
  139. "ACPI PM1b_EVT_BLK");
  140. acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length,
  141. "ACPI PM1a_CNT_BLK");
  142. acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length,
  143. "ACPI PM1b_CNT_BLK");
  144. if (acpi_gbl_FADT.pm_timer_length == 4)
  145. acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR");
  146. acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length,
  147. "ACPI PM2_CNT_BLK");
  148. /* Length of GPE blocks must be a non-negative multiple of 2 */
  149. if (!(acpi_gbl_FADT.gpe0_block_length & 0x1))
  150. acpi_request_region(&acpi_gbl_FADT.xgpe0_block,
  151. acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK");
  152. if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
  153. acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
  154. acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
  155. return 0;
  156. }
  157. device_initcall(acpi_reserve_resources);
  158. acpi_status __init acpi_os_initialize(void)
  159. {
  160. return AE_OK;
  161. }
  162. acpi_status acpi_os_initialize1(void)
  163. {
  164. kacpid_wq = create_singlethread_workqueue("kacpid");
  165. kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
  166. BUG_ON(!kacpid_wq);
  167. BUG_ON(!kacpi_notify_wq);
  168. return AE_OK;
  169. }
  170. acpi_status acpi_os_terminate(void)
  171. {
  172. if (acpi_irq_handler) {
  173. acpi_os_remove_interrupt_handler(acpi_irq_irq,
  174. acpi_irq_handler);
  175. }
  176. destroy_workqueue(kacpid_wq);
  177. destroy_workqueue(kacpi_notify_wq);
  178. return AE_OK;
  179. }
  180. void acpi_os_printf(const char *fmt, ...)
  181. {
  182. va_list args;
  183. va_start(args, fmt);
  184. acpi_os_vprintf(fmt, args);
  185. va_end(args);
  186. }
  187. void acpi_os_vprintf(const char *fmt, va_list args)
  188. {
  189. static char buffer[512];
  190. vsprintf(buffer, fmt, args);
  191. #ifdef ENABLE_DEBUGGER
  192. if (acpi_in_debugger) {
  193. kdb_printf("%s", buffer);
  194. } else {
  195. printk("%s", buffer);
  196. }
  197. #else
  198. printk("%s", buffer);
  199. #endif
  200. }
  201. acpi_physical_address __init acpi_os_get_root_pointer(void)
  202. {
  203. if (efi_enabled) {
  204. if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
  205. return efi.acpi20;
  206. else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
  207. return efi.acpi;
  208. else {
  209. printk(KERN_ERR PREFIX
  210. "System description tables not found\n");
  211. return 0;
  212. }
  213. } else {
  214. acpi_physical_address pa = 0;
  215. acpi_find_root_pointer(&pa);
  216. return pa;
  217. }
  218. }
  219. void __iomem *__init_refok
  220. acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
  221. {
  222. if (phys > ULONG_MAX) {
  223. printk(KERN_ERR PREFIX "Cannot map memory that high\n");
  224. return NULL;
  225. }
  226. if (acpi_gbl_permanent_mmap)
  227. /*
  228. * ioremap checks to ensure this is in reserved space
  229. */
  230. return ioremap((unsigned long)phys, size);
  231. else
  232. return __acpi_map_table((unsigned long)phys, size);
  233. }
  234. EXPORT_SYMBOL_GPL(acpi_os_map_memory);
  235. void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
  236. {
  237. if (acpi_gbl_permanent_mmap) {
  238. iounmap(virt);
  239. }
  240. }
  241. EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
  242. #ifdef ACPI_FUTURE_USAGE
  243. acpi_status
  244. acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
  245. {
  246. if (!phys || !virt)
  247. return AE_BAD_PARAMETER;
  248. *phys = virt_to_phys(virt);
  249. return AE_OK;
  250. }
  251. #endif
  252. #define ACPI_MAX_OVERRIDE_LEN 100
  253. static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
  254. acpi_status
  255. acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
  256. acpi_string * new_val)
  257. {
  258. if (!init_val || !new_val)
  259. return AE_BAD_PARAMETER;
  260. *new_val = NULL;
  261. if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
  262. printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
  263. acpi_os_name);
  264. *new_val = acpi_os_name;
  265. }
  266. return AE_OK;
  267. }
  268. acpi_status
  269. acpi_os_table_override(struct acpi_table_header * existing_table,
  270. struct acpi_table_header ** new_table)
  271. {
  272. if (!existing_table || !new_table)
  273. return AE_BAD_PARAMETER;
  274. *new_table = NULL;
  275. #ifdef CONFIG_ACPI_CUSTOM_DSDT
  276. if (strncmp(existing_table->signature, "DSDT", 4) == 0)
  277. *new_table = (struct acpi_table_header *)AmlCode;
  278. #endif
  279. if (*new_table != NULL) {
  280. printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], "
  281. "this is unsafe: tainting kernel\n",
  282. existing_table->signature,
  283. existing_table->oem_table_id);
  284. add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
  285. }
  286. return AE_OK;
  287. }
  288. static irqreturn_t acpi_irq(int irq, void *dev_id)
  289. {
  290. u32 handled;
  291. handled = (*acpi_irq_handler) (acpi_irq_context);
  292. if (handled) {
  293. acpi_irq_handled++;
  294. return IRQ_HANDLED;
  295. } else
  296. return IRQ_NONE;
  297. }
  298. acpi_status
  299. acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
  300. void *context)
  301. {
  302. unsigned int irq;
  303. acpi_irq_stats_init();
  304. /*
  305. * Ignore the GSI from the core, and use the value in our copy of the
  306. * FADT. It may not be the same if an interrupt source override exists
  307. * for the SCI.
  308. */
  309. gsi = acpi_gbl_FADT.sci_interrupt;
  310. if (acpi_gsi_to_irq(gsi, &irq) < 0) {
  311. printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
  312. gsi);
  313. return AE_OK;
  314. }
  315. acpi_irq_handler = handler;
  316. acpi_irq_context = context;
  317. if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
  318. printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
  319. return AE_NOT_ACQUIRED;
  320. }
  321. acpi_irq_irq = irq;
  322. return AE_OK;
  323. }
  324. acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
  325. {
  326. if (irq) {
  327. free_irq(irq, acpi_irq);
  328. acpi_irq_handler = NULL;
  329. acpi_irq_irq = 0;
  330. }
  331. return AE_OK;
  332. }
  333. /*
  334. * Running in interpreter thread context, safe to sleep
  335. */
  336. void acpi_os_sleep(acpi_integer ms)
  337. {
  338. schedule_timeout_interruptible(msecs_to_jiffies(ms));
  339. }
  340. void acpi_os_stall(u32 us)
  341. {
  342. while (us) {
  343. u32 delay = 1000;
  344. if (delay > us)
  345. delay = us;
  346. udelay(delay);
  347. touch_nmi_watchdog();
  348. us -= delay;
  349. }
  350. }
  351. /*
  352. * Support ACPI 3.0 AML Timer operand
  353. * Returns 64-bit free-running, monotonically increasing timer
  354. * with 100ns granularity
  355. */
  356. u64 acpi_os_get_timer(void)
  357. {
  358. static u64 t;
  359. #ifdef CONFIG_HPET
  360. /* TBD: use HPET if available */
  361. #endif
  362. #ifdef CONFIG_X86_PM_TIMER
  363. /* TBD: default to PM timer if HPET was not available */
  364. #endif
  365. if (!t)
  366. printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
  367. return ++t;
  368. }
  369. acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
  370. {
  371. u32 dummy;
  372. if (!value)
  373. value = &dummy;
  374. *value = 0;
  375. if (width <= 8) {
  376. *(u8 *) value = inb(port);
  377. } else if (width <= 16) {
  378. *(u16 *) value = inw(port);
  379. } else if (width <= 32) {
  380. *(u32 *) value = inl(port);
  381. } else {
  382. BUG();
  383. }
  384. return AE_OK;
  385. }
  386. EXPORT_SYMBOL(acpi_os_read_port);
  387. acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
  388. {
  389. if (width <= 8) {
  390. outb(value, port);
  391. } else if (width <= 16) {
  392. outw(value, port);
  393. } else if (width <= 32) {
  394. outl(value, port);
  395. } else {
  396. BUG();
  397. }
  398. return AE_OK;
  399. }
  400. EXPORT_SYMBOL(acpi_os_write_port);
  401. acpi_status
  402. acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
  403. {
  404. u32 dummy;
  405. void __iomem *virt_addr;
  406. virt_addr = ioremap(phys_addr, width);
  407. if (!value)
  408. value = &dummy;
  409. switch (width) {
  410. case 8:
  411. *(u8 *) value = readb(virt_addr);
  412. break;
  413. case 16:
  414. *(u16 *) value = readw(virt_addr);
  415. break;
  416. case 32:
  417. *(u32 *) value = readl(virt_addr);
  418. break;
  419. default:
  420. BUG();
  421. }
  422. iounmap(virt_addr);
  423. return AE_OK;
  424. }
  425. acpi_status
  426. acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
  427. {
  428. void __iomem *virt_addr;
  429. virt_addr = ioremap(phys_addr, width);
  430. switch (width) {
  431. case 8:
  432. writeb(value, virt_addr);
  433. break;
  434. case 16:
  435. writew(value, virt_addr);
  436. break;
  437. case 32:
  438. writel(value, virt_addr);
  439. break;
  440. default:
  441. BUG();
  442. }
  443. iounmap(virt_addr);
  444. return AE_OK;
  445. }
  446. acpi_status
  447. acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
  448. u32 *value, u32 width)
  449. {
  450. int result, size;
  451. if (!value)
  452. return AE_BAD_PARAMETER;
  453. switch (width) {
  454. case 8:
  455. size = 1;
  456. break;
  457. case 16:
  458. size = 2;
  459. break;
  460. case 32:
  461. size = 4;
  462. break;
  463. default:
  464. return AE_ERROR;
  465. }
  466. result = raw_pci_read(pci_id->segment, pci_id->bus,
  467. PCI_DEVFN(pci_id->device, pci_id->function),
  468. reg, size, value);
  469. return (result ? AE_ERROR : AE_OK);
  470. }
  471. acpi_status
  472. acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
  473. acpi_integer value, u32 width)
  474. {
  475. int result, size;
  476. switch (width) {
  477. case 8:
  478. size = 1;
  479. break;
  480. case 16:
  481. size = 2;
  482. break;
  483. case 32:
  484. size = 4;
  485. break;
  486. default:
  487. return AE_ERROR;
  488. }
  489. result = raw_pci_write(pci_id->segment, pci_id->bus,
  490. PCI_DEVFN(pci_id->device, pci_id->function),
  491. reg, size, value);
  492. return (result ? AE_ERROR : AE_OK);
  493. }
  494. /* TODO: Change code to take advantage of driver model more */
  495. static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
  496. acpi_handle chandle, /* current node */
  497. struct acpi_pci_id **id,
  498. int *is_bridge, u8 * bus_number)
  499. {
  500. acpi_handle handle;
  501. struct acpi_pci_id *pci_id = *id;
  502. acpi_status status;
  503. unsigned long long temp;
  504. acpi_object_type type;
  505. acpi_get_parent(chandle, &handle);
  506. if (handle != rhandle) {
  507. acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
  508. bus_number);
  509. status = acpi_get_type(handle, &type);
  510. if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
  511. return;
  512. status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
  513. &temp);
  514. if (ACPI_SUCCESS(status)) {
  515. u32 val;
  516. pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
  517. pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
  518. if (*is_bridge)
  519. pci_id->bus = *bus_number;
  520. /* any nicer way to get bus number of bridge ? */
  521. status =
  522. acpi_os_read_pci_configuration(pci_id, 0x0e, &val,
  523. 8);
  524. if (ACPI_SUCCESS(status)
  525. && ((val & 0x7f) == 1 || (val & 0x7f) == 2)) {
  526. status =
  527. acpi_os_read_pci_configuration(pci_id, 0x18,
  528. &val, 8);
  529. if (!ACPI_SUCCESS(status)) {
  530. /* Certainly broken... FIX ME */
  531. return;
  532. }
  533. *is_bridge = 1;
  534. pci_id->bus = val;
  535. status =
  536. acpi_os_read_pci_configuration(pci_id, 0x19,
  537. &val, 8);
  538. if (ACPI_SUCCESS(status)) {
  539. *bus_number = val;
  540. }
  541. } else
  542. *is_bridge = 0;
  543. }
  544. }
  545. }
  546. void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
  547. acpi_handle chandle, /* current node */
  548. struct acpi_pci_id **id)
  549. {
  550. int is_bridge = 1;
  551. u8 bus_number = (*id)->bus;
  552. acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
  553. }
  554. static void acpi_os_execute_deferred(struct work_struct *work)
  555. {
  556. struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
  557. if (!dpc) {
  558. printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
  559. return;
  560. }
  561. dpc->function(dpc->context);
  562. kfree(dpc);
  563. return;
  564. }
  565. static void acpi_os_execute_hp_deferred(struct work_struct *work)
  566. {
  567. struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
  568. if (!dpc) {
  569. printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
  570. return;
  571. }
  572. acpi_os_wait_events_complete(NULL);
  573. dpc->function(dpc->context);
  574. kfree(dpc);
  575. return;
  576. }
  577. /*******************************************************************************
  578. *
  579. * FUNCTION: acpi_os_execute
  580. *
  581. * PARAMETERS: Type - Type of the callback
  582. * Function - Function to be executed
  583. * Context - Function parameters
  584. *
  585. * RETURN: Status
  586. *
  587. * DESCRIPTION: Depending on type, either queues function for deferred execution or
  588. * immediately executes function on a separate thread.
  589. *
  590. ******************************************************************************/
  591. static acpi_status __acpi_os_execute(acpi_execute_type type,
  592. acpi_osd_exec_callback function, void *context, int hp)
  593. {
  594. acpi_status status = AE_OK;
  595. struct acpi_os_dpc *dpc;
  596. struct workqueue_struct *queue;
  597. int ret;
  598. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  599. "Scheduling function [%p(%p)] for deferred execution.\n",
  600. function, context));
  601. if (!function)
  602. return AE_BAD_PARAMETER;
  603. /*
  604. * Allocate/initialize DPC structure. Note that this memory will be
  605. * freed by the callee. The kernel handles the work_struct list in a
  606. * way that allows us to also free its memory inside the callee.
  607. * Because we may want to schedule several tasks with different
  608. * parameters we can't use the approach some kernel code uses of
  609. * having a static work_struct.
  610. */
  611. dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
  612. if (!dpc)
  613. return_ACPI_STATUS(AE_NO_MEMORY);
  614. dpc->function = function;
  615. dpc->context = context;
  616. if (!hp) {
  617. INIT_WORK(&dpc->work, acpi_os_execute_deferred);
  618. queue = (type == OSL_NOTIFY_HANDLER) ?
  619. kacpi_notify_wq : kacpid_wq;
  620. ret = queue_work(queue, &dpc->work);
  621. } else {
  622. INIT_WORK(&dpc->work, acpi_os_execute_hp_deferred);
  623. ret = schedule_work(&dpc->work);
  624. }
  625. if (!ret) {
  626. printk(KERN_ERR PREFIX
  627. "Call to queue_work() failed.\n");
  628. status = AE_ERROR;
  629. kfree(dpc);
  630. }
  631. return_ACPI_STATUS(status);
  632. }
  633. acpi_status acpi_os_execute(acpi_execute_type type,
  634. acpi_osd_exec_callback function, void *context)
  635. {
  636. return __acpi_os_execute(type, function, context, 0);
  637. }
  638. EXPORT_SYMBOL(acpi_os_execute);
  639. acpi_status acpi_os_hotplug_execute(acpi_osd_exec_callback function,
  640. void *context)
  641. {
  642. return __acpi_os_execute(0, function, context, 1);
  643. }
  644. void acpi_os_wait_events_complete(void *context)
  645. {
  646. flush_workqueue(kacpid_wq);
  647. flush_workqueue(kacpi_notify_wq);
  648. }
  649. EXPORT_SYMBOL(acpi_os_wait_events_complete);
  650. /*
  651. * Allocate the memory for a spinlock and initialize it.
  652. */
  653. acpi_status acpi_os_create_lock(acpi_spinlock * handle)
  654. {
  655. spin_lock_init(*handle);
  656. return AE_OK;
  657. }
  658. /*
  659. * Deallocate the memory for a spinlock.
  660. */
  661. void acpi_os_delete_lock(acpi_spinlock handle)
  662. {
  663. return;
  664. }
  665. acpi_status
  666. acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
  667. {
  668. struct semaphore *sem = NULL;
  669. sem = acpi_os_allocate(sizeof(struct semaphore));
  670. if (!sem)
  671. return AE_NO_MEMORY;
  672. memset(sem, 0, sizeof(struct semaphore));
  673. sema_init(sem, initial_units);
  674. *handle = (acpi_handle *) sem;
  675. ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
  676. *handle, initial_units));
  677. return AE_OK;
  678. }
  679. /*
  680. * TODO: A better way to delete semaphores? Linux doesn't have a
  681. * 'delete_semaphore()' function -- may result in an invalid
  682. * pointer dereference for non-synchronized consumers. Should
  683. * we at least check for blocked threads and signal/cancel them?
  684. */
  685. acpi_status acpi_os_delete_semaphore(acpi_handle handle)
  686. {
  687. struct semaphore *sem = (struct semaphore *)handle;
  688. if (!sem)
  689. return AE_BAD_PARAMETER;
  690. ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
  691. BUG_ON(!list_empty(&sem->wait_list));
  692. kfree(sem);
  693. sem = NULL;
  694. return AE_OK;
  695. }
  696. /*
  697. * TODO: Support for units > 1?
  698. */
  699. acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
  700. {
  701. acpi_status status = AE_OK;
  702. struct semaphore *sem = (struct semaphore *)handle;
  703. long jiffies;
  704. int ret = 0;
  705. if (!sem || (units < 1))
  706. return AE_BAD_PARAMETER;
  707. if (units > 1)
  708. return AE_SUPPORT;
  709. ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
  710. handle, units, timeout));
  711. if (timeout == ACPI_WAIT_FOREVER)
  712. jiffies = MAX_SCHEDULE_TIMEOUT;
  713. else
  714. jiffies = msecs_to_jiffies(timeout);
  715. ret = down_timeout(sem, jiffies);
  716. if (ret)
  717. status = AE_TIME;
  718. if (ACPI_FAILURE(status)) {
  719. ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
  720. "Failed to acquire semaphore[%p|%d|%d], %s",
  721. handle, units, timeout,
  722. acpi_format_exception(status)));
  723. } else {
  724. ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
  725. "Acquired semaphore[%p|%d|%d]", handle,
  726. units, timeout));
  727. }
  728. return status;
  729. }
  730. /*
  731. * TODO: Support for units > 1?
  732. */
  733. acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
  734. {
  735. struct semaphore *sem = (struct semaphore *)handle;
  736. if (!sem || (units < 1))
  737. return AE_BAD_PARAMETER;
  738. if (units > 1)
  739. return AE_SUPPORT;
  740. ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
  741. units));
  742. up(sem);
  743. return AE_OK;
  744. }
  745. #ifdef ACPI_FUTURE_USAGE
  746. u32 acpi_os_get_line(char *buffer)
  747. {
  748. #ifdef ENABLE_DEBUGGER
  749. if (acpi_in_debugger) {
  750. u32 chars;
  751. kdb_read(buffer, sizeof(line_buf));
  752. /* remove the CR kdb includes */
  753. chars = strlen(buffer) - 1;
  754. buffer[chars] = '\0';
  755. }
  756. #endif
  757. return 0;
  758. }
  759. #endif /* ACPI_FUTURE_USAGE */
  760. acpi_status acpi_os_signal(u32 function, void *info)
  761. {
  762. switch (function) {
  763. case ACPI_SIGNAL_FATAL:
  764. printk(KERN_ERR PREFIX "Fatal opcode executed\n");
  765. break;
  766. case ACPI_SIGNAL_BREAKPOINT:
  767. /*
  768. * AML Breakpoint
  769. * ACPI spec. says to treat it as a NOP unless
  770. * you are debugging. So if/when we integrate
  771. * AML debugger into the kernel debugger its
  772. * hook will go here. But until then it is
  773. * not useful to print anything on breakpoints.
  774. */
  775. break;
  776. default:
  777. break;
  778. }
  779. return AE_OK;
  780. }
  781. static int __init acpi_os_name_setup(char *str)
  782. {
  783. char *p = acpi_os_name;
  784. int count = ACPI_MAX_OVERRIDE_LEN - 1;
  785. if (!str || !*str)
  786. return 0;
  787. for (; count-- && str && *str; str++) {
  788. if (isalnum(*str) || *str == ' ' || *str == ':')
  789. *p++ = *str;
  790. else if (*str == '\'' || *str == '"')
  791. continue;
  792. else
  793. break;
  794. }
  795. *p = 0;
  796. return 1;
  797. }
  798. __setup("acpi_os_name=", acpi_os_name_setup);
  799. static void __init set_osi_linux(unsigned int enable)
  800. {
  801. if (osi_linux.enable != enable) {
  802. osi_linux.enable = enable;
  803. printk(KERN_NOTICE PREFIX "%sed _OSI(Linux)\n",
  804. enable ? "Add": "Delet");
  805. }
  806. return;
  807. }
  808. static void __init acpi_cmdline_osi_linux(unsigned int enable)
  809. {
  810. osi_linux.cmdline = 1; /* cmdline set the default */
  811. set_osi_linux(enable);
  812. return;
  813. }
  814. void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
  815. {
  816. osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */
  817. printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
  818. if (enable == -1)
  819. return;
  820. osi_linux.known = 1; /* DMI knows which OSI(Linux) default needed */
  821. set_osi_linux(enable);
  822. return;
  823. }
  824. /*
  825. * Modify the list of "OS Interfaces" reported to BIOS via _OSI
  826. *
  827. * empty string disables _OSI
  828. * string starting with '!' disables that string
  829. * otherwise string is added to list, augmenting built-in strings
  830. */
  831. int __init acpi_osi_setup(char *str)
  832. {
  833. if (str == NULL || *str == '\0') {
  834. printk(KERN_INFO PREFIX "_OSI method disabled\n");
  835. acpi_gbl_create_osi_method = FALSE;
  836. } else if (!strcmp("!Linux", str)) {
  837. acpi_cmdline_osi_linux(0); /* !enable */
  838. } else if (*str == '!') {
  839. if (acpi_osi_invalidate(++str) == AE_OK)
  840. printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
  841. } else if (!strcmp("Linux", str)) {
  842. acpi_cmdline_osi_linux(1); /* enable */
  843. } else if (*osi_additional_string == '\0') {
  844. strncpy(osi_additional_string, str, OSI_STRING_LENGTH_MAX);
  845. printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
  846. }
  847. return 1;
  848. }
  849. __setup("acpi_osi=", acpi_osi_setup);
  850. /* enable serialization to combat AE_ALREADY_EXISTS errors */
  851. static int __init acpi_serialize_setup(char *str)
  852. {
  853. printk(KERN_INFO PREFIX "serialize enabled\n");
  854. acpi_gbl_all_methods_serialized = TRUE;
  855. return 1;
  856. }
  857. __setup("acpi_serialize", acpi_serialize_setup);
  858. /*
  859. * Wake and Run-Time GPES are expected to be separate.
  860. * We disable wake-GPEs at run-time to prevent spurious
  861. * interrupts.
  862. *
  863. * However, if a system exists that shares Wake and
  864. * Run-time events on the same GPE this flag is available
  865. * to tell Linux to keep the wake-time GPEs enabled at run-time.
  866. */
  867. static int __init acpi_wake_gpes_always_on_setup(char *str)
  868. {
  869. printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
  870. acpi_gbl_leave_wake_gpes_disabled = FALSE;
  871. return 1;
  872. }
  873. __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
  874. /* Check of resource interference between native drivers and ACPI
  875. * OperationRegions (SystemIO and System Memory only).
  876. * IO ports and memory declared in ACPI might be used by the ACPI subsystem
  877. * in arbitrary AML code and can interfere with legacy drivers.
  878. * acpi_enforce_resources= can be set to:
  879. *
  880. * - strict (2)
  881. * -> further driver trying to access the resources will not load
  882. * - lax (default) (1)
  883. * -> further driver trying to access the resources will load, but you
  884. * get a system message that something might go wrong...
  885. *
  886. * - no (0)
  887. * -> ACPI Operation Region resources will not be registered
  888. *
  889. */
  890. #define ENFORCE_RESOURCES_STRICT 2
  891. #define ENFORCE_RESOURCES_LAX 1
  892. #define ENFORCE_RESOURCES_NO 0
  893. static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_LAX;
  894. static int __init acpi_enforce_resources_setup(char *str)
  895. {
  896. if (str == NULL || *str == '\0')
  897. return 0;
  898. if (!strcmp("strict", str))
  899. acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
  900. else if (!strcmp("lax", str))
  901. acpi_enforce_resources = ENFORCE_RESOURCES_LAX;
  902. else if (!strcmp("no", str))
  903. acpi_enforce_resources = ENFORCE_RESOURCES_NO;
  904. return 1;
  905. }
  906. __setup("acpi_enforce_resources=", acpi_enforce_resources_setup);
  907. /* Check for resource conflicts between ACPI OperationRegions and native
  908. * drivers */
  909. int acpi_check_resource_conflict(struct resource *res)
  910. {
  911. struct acpi_res_list *res_list_elem;
  912. int ioport;
  913. int clash = 0;
  914. if (acpi_enforce_resources == ENFORCE_RESOURCES_NO)
  915. return 0;
  916. if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM))
  917. return 0;
  918. ioport = res->flags & IORESOURCE_IO;
  919. spin_lock(&acpi_res_lock);
  920. list_for_each_entry(res_list_elem, &resource_list_head,
  921. resource_list) {
  922. if (ioport && (res_list_elem->resource_type
  923. != ACPI_ADR_SPACE_SYSTEM_IO))
  924. continue;
  925. if (!ioport && (res_list_elem->resource_type
  926. != ACPI_ADR_SPACE_SYSTEM_MEMORY))
  927. continue;
  928. if (res->end < res_list_elem->start
  929. || res_list_elem->end < res->start)
  930. continue;
  931. clash = 1;
  932. break;
  933. }
  934. spin_unlock(&acpi_res_lock);
  935. if (clash) {
  936. if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) {
  937. printk("%sACPI: %s resource %s [0x%llx-0x%llx]"
  938. " conflicts with ACPI region %s"
  939. " [0x%llx-0x%llx]\n",
  940. acpi_enforce_resources == ENFORCE_RESOURCES_LAX
  941. ? KERN_WARNING : KERN_ERR,
  942. ioport ? "I/O" : "Memory", res->name,
  943. (long long) res->start, (long long) res->end,
  944. res_list_elem->name,
  945. (long long) res_list_elem->start,
  946. (long long) res_list_elem->end);
  947. printk(KERN_INFO "ACPI: Device needs an ACPI driver\n");
  948. }
  949. if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT)
  950. return -EBUSY;
  951. }
  952. return 0;
  953. }
  954. EXPORT_SYMBOL(acpi_check_resource_conflict);
  955. int acpi_check_region(resource_size_t start, resource_size_t n,
  956. const char *name)
  957. {
  958. struct resource res = {
  959. .start = start,
  960. .end = start + n - 1,
  961. .name = name,
  962. .flags = IORESOURCE_IO,
  963. };
  964. return acpi_check_resource_conflict(&res);
  965. }
  966. EXPORT_SYMBOL(acpi_check_region);
  967. int acpi_check_mem_region(resource_size_t start, resource_size_t n,
  968. const char *name)
  969. {
  970. struct resource res = {
  971. .start = start,
  972. .end = start + n - 1,
  973. .name = name,
  974. .flags = IORESOURCE_MEM,
  975. };
  976. return acpi_check_resource_conflict(&res);
  977. }
  978. EXPORT_SYMBOL(acpi_check_mem_region);
  979. /*
  980. * Acquire a spinlock.
  981. *
  982. * handle is a pointer to the spinlock_t.
  983. */
  984. acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
  985. {
  986. acpi_cpu_flags flags;
  987. spin_lock_irqsave(lockp, flags);
  988. return flags;
  989. }
  990. /*
  991. * Release a spinlock. See above.
  992. */
  993. void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
  994. {
  995. spin_unlock_irqrestore(lockp, flags);
  996. }
  997. #ifndef ACPI_USE_LOCAL_CACHE
  998. /*******************************************************************************
  999. *
  1000. * FUNCTION: acpi_os_create_cache
  1001. *
  1002. * PARAMETERS: name - Ascii name for the cache
  1003. * size - Size of each cached object
  1004. * depth - Maximum depth of the cache (in objects) <ignored>
  1005. * cache - Where the new cache object is returned
  1006. *
  1007. * RETURN: status
  1008. *
  1009. * DESCRIPTION: Create a cache object
  1010. *
  1011. ******************************************************************************/
  1012. acpi_status
  1013. acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
  1014. {
  1015. *cache = kmem_cache_create(name, size, 0, 0, NULL);
  1016. if (*cache == NULL)
  1017. return AE_ERROR;
  1018. else
  1019. return AE_OK;
  1020. }
  1021. /*******************************************************************************
  1022. *
  1023. * FUNCTION: acpi_os_purge_cache
  1024. *
  1025. * PARAMETERS: Cache - Handle to cache object
  1026. *
  1027. * RETURN: Status
  1028. *
  1029. * DESCRIPTION: Free all objects within the requested cache.
  1030. *
  1031. ******************************************************************************/
  1032. acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
  1033. {
  1034. kmem_cache_shrink(cache);
  1035. return (AE_OK);
  1036. }
  1037. /*******************************************************************************
  1038. *
  1039. * FUNCTION: acpi_os_delete_cache
  1040. *
  1041. * PARAMETERS: Cache - Handle to cache object
  1042. *
  1043. * RETURN: Status
  1044. *
  1045. * DESCRIPTION: Free all objects within the requested cache and delete the
  1046. * cache object.
  1047. *
  1048. ******************************************************************************/
  1049. acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
  1050. {
  1051. kmem_cache_destroy(cache);
  1052. return (AE_OK);
  1053. }
  1054. /*******************************************************************************
  1055. *
  1056. * FUNCTION: acpi_os_release_object
  1057. *
  1058. * PARAMETERS: Cache - Handle to cache object
  1059. * Object - The object to be released
  1060. *
  1061. * RETURN: None
  1062. *
  1063. * DESCRIPTION: Release an object to the specified cache. If cache is full,
  1064. * the object is deleted.
  1065. *
  1066. ******************************************************************************/
  1067. acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
  1068. {
  1069. kmem_cache_free(cache, object);
  1070. return (AE_OK);
  1071. }
  1072. /******************************************************************************
  1073. *
  1074. * FUNCTION: acpi_os_validate_interface
  1075. *
  1076. * PARAMETERS: interface - Requested interface to be validated
  1077. *
  1078. * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
  1079. *
  1080. * DESCRIPTION: Match an interface string to the interfaces supported by the
  1081. * host. Strings originate from an AML call to the _OSI method.
  1082. *
  1083. *****************************************************************************/
  1084. acpi_status
  1085. acpi_os_validate_interface (char *interface)
  1086. {
  1087. if (!strncmp(osi_additional_string, interface, OSI_STRING_LENGTH_MAX))
  1088. return AE_OK;
  1089. if (!strcmp("Linux", interface)) {
  1090. printk(KERN_NOTICE PREFIX
  1091. "BIOS _OSI(Linux) query %s%s\n",
  1092. osi_linux.enable ? "honored" : "ignored",
  1093. osi_linux.cmdline ? " via cmdline" :
  1094. osi_linux.dmi ? " via DMI" : "");
  1095. if (osi_linux.enable)
  1096. return AE_OK;
  1097. }
  1098. return AE_SUPPORT;
  1099. }
  1100. /******************************************************************************
  1101. *
  1102. * FUNCTION: acpi_os_validate_address
  1103. *
  1104. * PARAMETERS: space_id - ACPI space ID
  1105. * address - Physical address
  1106. * length - Address length
  1107. *
  1108. * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
  1109. * should return AE_AML_ILLEGAL_ADDRESS.
  1110. *
  1111. * DESCRIPTION: Validate a system address via the host OS. Used to validate
  1112. * the addresses accessed by AML operation regions.
  1113. *
  1114. *****************************************************************************/
  1115. acpi_status
  1116. acpi_os_validate_address (
  1117. u8 space_id,
  1118. acpi_physical_address address,
  1119. acpi_size length,
  1120. char *name)
  1121. {
  1122. struct acpi_res_list *res;
  1123. if (acpi_enforce_resources == ENFORCE_RESOURCES_NO)
  1124. return AE_OK;
  1125. switch (space_id) {
  1126. case ACPI_ADR_SPACE_SYSTEM_IO:
  1127. case ACPI_ADR_SPACE_SYSTEM_MEMORY:
  1128. /* Only interference checks against SystemIO and SytemMemory
  1129. are needed */
  1130. res = kzalloc(sizeof(struct acpi_res_list), GFP_KERNEL);
  1131. if (!res)
  1132. return AE_OK;
  1133. /* ACPI names are fixed to 4 bytes, still better use strlcpy */
  1134. strlcpy(res->name, name, 5);
  1135. res->start = address;
  1136. res->end = address + length - 1;
  1137. res->resource_type = space_id;
  1138. spin_lock(&acpi_res_lock);
  1139. list_add(&res->resource_list, &resource_list_head);
  1140. spin_unlock(&acpi_res_lock);
  1141. pr_debug("Added %s resource: start: 0x%llx, end: 0x%llx, "
  1142. "name: %s\n", (space_id == ACPI_ADR_SPACE_SYSTEM_IO)
  1143. ? "SystemIO" : "System Memory",
  1144. (unsigned long long)res->start,
  1145. (unsigned long long)res->end,
  1146. res->name);
  1147. break;
  1148. case ACPI_ADR_SPACE_PCI_CONFIG:
  1149. case ACPI_ADR_SPACE_EC:
  1150. case ACPI_ADR_SPACE_SMBUS:
  1151. case ACPI_ADR_SPACE_CMOS:
  1152. case ACPI_ADR_SPACE_PCI_BAR_TARGET:
  1153. case ACPI_ADR_SPACE_DATA_TABLE:
  1154. case ACPI_ADR_SPACE_FIXED_HARDWARE:
  1155. break;
  1156. }
  1157. return AE_OK;
  1158. }
  1159. #endif