osl.c 35 KB

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