osl.c 34 KB

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