devacpi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "u.h"
  10. #include "../port/lib.h"
  11. #include "mem.h"
  12. #include "dat.h"
  13. #include "fns.h"
  14. #include "io.h"
  15. #include "../port/error.h"
  16. #include "mp.h"
  17. #include <acpi/acpica/acpi.h>
  18. enum
  19. {
  20. Sdthdrsz = 36, /* size of SDT header */
  21. Qdir = 0,
  22. Qctl,
  23. Qtbl,
  24. Qio,
  25. };
  26. #if 0
  27. static Cmdtab ctls[] =
  28. {
  29. {CMregion, "region", 6},
  30. {CMgpe, "gpe", 3},
  31. };
  32. #endif
  33. static Dirtab acpidir[]={
  34. ".", {Qdir, 0, QTDIR}, 0, DMDIR|0555,
  35. "acpictl", {Qctl}, 0, 0666,
  36. "acpitbl", {Qtbl}, 0, 0444,
  37. "acpiregio", {Qio}, 0, 0666,
  38. };
  39. #if 0
  40. static char* regnames[] = {
  41. "mem", "io", "pcicfg", "embed",
  42. "smb", "cmos", "pcibar",
  43. };
  44. #endif
  45. static void *rsd;
  46. /*
  47. * we use mp->machno (or index in Mach array) as the identifier,
  48. * but ACPI relies on the apic identifier.
  49. */
  50. int
  51. corecolor(int core)
  52. {
  53. Mach *m;
  54. static int colors[32];
  55. if(core < 0 || core >= MACHMAX)
  56. return -1;
  57. m = sys->machptr[core];
  58. if(m == nil)
  59. return -1;
  60. if(core >= 0 && core < nelem(colors) && colors[core] != 0)
  61. return colors[core] - 1;
  62. return -1;
  63. }
  64. int
  65. pickcore(int mycolor, int index)
  66. {
  67. return 0;
  68. }
  69. static void*
  70. rsdscan(uint8_t* addr, int len, char* signature)
  71. {
  72. int sl;
  73. uint8_t *e, *p;
  74. e = addr+len;
  75. sl = strlen(signature);
  76. for(p = addr; p+sl < e; p += 16){
  77. if(memcmp(p, signature, sl))
  78. continue;
  79. return p;
  80. }
  81. return nil;
  82. }
  83. static void*
  84. rsdsearch(char* signature)
  85. {
  86. uintptr_t p;
  87. uint8_t *bda;
  88. void *rsd;
  89. /*
  90. * Search for the data structure signature:
  91. * 1) in the first KB of the EBDA;
  92. * 2) in the BIOS ROM between 0xE0000 and 0xFFFFF.
  93. */
  94. if(strncmp((char*)KADDR(0xFFFD9), "EISA", 4) == 0){
  95. bda = BIOSSEG(0x40);
  96. if((p = (bda[0x0F]<<8)|bda[0x0E])){
  97. if(rsd = rsdscan(KADDR(p), 1024, signature))
  98. return rsd;
  99. }
  100. }
  101. return rsdscan(BIOSSEG(0xE000), 0x20000, signature);
  102. }
  103. static void
  104. acpirsdptr(void)
  105. {
  106. rsd = rsdsearch("RSD PTR ");
  107. if (rsd == nil) {
  108. print("NO RSD PTR found\n");
  109. return;
  110. }
  111. print("Found RST PTR ta %p\n", rsd);
  112. #if 0
  113. assert(sizeof(Sdthdr) == 36);
  114. DBG("acpi: RSD PTR@ %#p, physaddr %#ux length %ud %#llux rev %d\n",
  115. rsd, l32get(rsd->raddr), l32get(rsd->length),
  116. l64get(rsd->xaddr), rsd->revision);
  117. if(rsd->revision >= 2){
  118. if(sdtchecksum(rsd, 36) == nil){
  119. DBG("acpi: RSD: bad checksum\n");
  120. return;
  121. }
  122. sdtpa = l64get(rsd->xaddr);
  123. asize = 8;
  124. }
  125. else{
  126. if(sdtchecksum(rsd, 20) == nil){
  127. DBG("acpi: RSD: bad checksum\n");
  128. return;
  129. }
  130. sdtpa = l32get(rsd->raddr);
  131. asize = 4;
  132. }
  133. /*
  134. * process the RSDT or XSDT table.
  135. */
  136. xsdt = malloc(sizeof(Xsdt));
  137. if(xsdt == nil){
  138. DBG("acpi: malloc failed\n");
  139. return;
  140. }
  141. if((xsdt->p = sdtmap(sdtpa, &xsdt->len, 1)) == nil){
  142. DBG("acpi: sdtmap failed\n");
  143. return;
  144. }
  145. if((xsdt->p[0] != 'R' && xsdt->p[0] != 'X') || memcmp(xsdt->p+1, "SDT", 3) != 0){
  146. DBG("acpi: xsdt sig: %c%c%c%c\n",
  147. xsdt->p[0], xsdt->p[1], xsdt->p[2], xsdt->p[3]);
  148. free(xsdt);
  149. xsdt = nil;
  150. vunmap(xsdt, xsdt->len);
  151. return;
  152. }
  153. xsdt->p += sizeof(Sdthdr);
  154. xsdt->len -= sizeof(Sdthdr);
  155. xsdt->asize = asize;
  156. DBG("acpi: XSDT %#p\n", xsdt);
  157. acpixsdtload(nil);
  158. /* xsdt is kept and not unmapped */
  159. #endif
  160. }
  161. static int
  162. acpigen(Chan *c, char* d, Dirtab *tab, int ntab, int i, Dir *dp)
  163. {
  164. Qid qid;
  165. if(i == DEVDOTDOT){
  166. mkqid(&qid, Qdir, 0, QTDIR);
  167. devdir(c, qid, ".", 0, eve, 0555, dp);
  168. return 1;
  169. }
  170. i++; /* skip first element for . itself */
  171. if(tab==0 || i>=ntab)
  172. return -1;
  173. tab += i;
  174. qid = tab->qid;
  175. qid.path &= ~Qdir;
  176. qid.vers = 0;
  177. devdir(c, qid, tab->name, tab->length, eve, tab->perm, dp);
  178. return 1;
  179. }
  180. ACPI_STATUS
  181. AcpiOsInitialize(void)
  182. {
  183. print("%s\n", __func__);
  184. acpirsdptr();
  185. return AE_OK;
  186. }
  187. ACPI_STATUS
  188. AcpiOsTerminate (
  189. void)
  190. {
  191. print("%s\n", __func__);
  192. return AE_OK;
  193. }
  194. int
  195. acpiinit(void)
  196. {
  197. ACPI_TABLE_HEADER *h;
  198. int status;
  199. int apiccnt;
  200. status = AcpiInitializeSubsystem();
  201. if (ACPI_FAILURE(status))
  202. panic("can't start acpi");
  203. status = AcpiInitializeTables(NULL, 16, FALSE);
  204. if (ACPI_FAILURE(status))
  205. panic("can't set up acpi tables");
  206. status = AcpiLoadTables();
  207. if (ACPI_FAILURE(status))
  208. panic("Can't load ACPI tables");
  209. status = AcpiEnableSubsystem(0);
  210. if (ACPI_FAILURE(status))
  211. panic("Can't enable ACPI subsystem");
  212. status = AcpiInitializeObjects(0);
  213. if (ACPI_FAILURE(status))
  214. panic("Can't Initialize ACPI objects");
  215. for(apiccnt = 1; ;apiccnt++) {
  216. extern uint8_t *apicbase;
  217. ACPI_TABLE_MADT *m;
  218. status = AcpiGetTable(ACPI_SIG_MADT, apiccnt, &h);
  219. if (ACPI_FAILURE(status))
  220. break;
  221. m = (ACPI_TABLE_MADT *)h;
  222. print("APIC %d: %p 0x%x\n", apiccnt, (void *)(uint64_t)m->Address, m->Flags);
  223. if(apicbase == nil){
  224. if((apicbase = vmap((uintptr_t)m->Address, 1024)) == nil){
  225. panic("%s: can't map apicbase\n", __func__);
  226. }
  227. print("%s: apicbase %#p -> %#p\n", __func__, (void *)(uint64_t)m->Address, apicbase);
  228. }
  229. }
  230. if ((apiccnt == 1) && ACPI_FAILURE(status))
  231. panic("Can't find a MADT");
  232. return 0;
  233. }
  234. static Chan*
  235. acpiattach(char *spec)
  236. {
  237. return nil;
  238. // return devattach(L'α', spec);
  239. }
  240. static Walkqid*
  241. acpiwalk(Chan *c, Chan *nc, char **name, int nname)
  242. {
  243. return devwalk(c, nc, name, nname, acpidir, nelem(acpidir), acpigen);
  244. }
  245. static int32_t
  246. acpistat(Chan *c, uint8_t *dp, int32_t n)
  247. {
  248. return devstat(c, dp, n, acpidir, nelem(acpidir), acpigen);
  249. }
  250. static Chan*
  251. acpiopen(Chan *c, int omode)
  252. {
  253. return devopen(c, omode, acpidir, nelem(acpidir), acpigen);
  254. }
  255. static void
  256. acpiclose(Chan *c)
  257. {
  258. }
  259. #if 0
  260. static char*ttext;
  261. static int tlen;
  262. #endif
  263. static int32_t
  264. acpiread(Chan *c, void *a, int32_t n, int64_t off)
  265. {
  266. uint64_t q;
  267. q = c->qid.path;
  268. switch(q){
  269. case Qdir:
  270. return devdirread(c, a, n, acpidir, nelem(acpidir), acpigen);
  271. case Qtbl:
  272. return -1; //readstr(off, a, n, ttext);
  273. case Qio:
  274. return -1; //regio(reg, a, n, off, 0);
  275. }
  276. error(Eperm);
  277. return -1;
  278. }
  279. static int32_t
  280. acpiwrite(Chan *c, void *a, int32_t n, int64_t off)
  281. {
  282. if(c->qid.path == Qio){
  283. //if(reg == nil)
  284. error("region not configured");
  285. }
  286. if(c->qid.path != Qctl)
  287. error(Eperm);
  288. error("NP");
  289. #if 0
  290. cb = parsecmd(a, n);
  291. if(waserror()){
  292. free(cb);
  293. nexterror();
  294. }
  295. ct = lookupcmd(cb, ctls, nelem(ctls));
  296. DBG("acpi ctl %s\n", cb->f[0]);
  297. switch(ct->index){
  298. case CMregion:
  299. r = reg;
  300. if(r == nil){
  301. r = smalloc(sizeof(Reg));
  302. r->name = nil;
  303. }
  304. kstrdup(&r->name, cb->f[1]);
  305. r->spc = acpiregid(cb->f[2]);
  306. if(r->spc < 0){
  307. free(r);
  308. reg = nil;
  309. error("bad region type");
  310. }
  311. if(r->spc == Rpcicfg || r->spc == Rpcibar){
  312. rno = r->base>>Rpciregshift & Rpciregmask;
  313. fun = r->base>>Rpcifunshift & Rpcifunmask;
  314. dev = r->base>>Rpcidevshift & Rpcidevmask;
  315. bus = r->base>>Rpcibusshift & Rpcibusmask;
  316. r->tbdf = MKBUS(BusPCI, bus, dev, fun);
  317. r->base = rno; /* register ~ our base addr */
  318. }
  319. r->base = strtoull(cb->f[3], nil, 0);
  320. r->len = strtoull(cb->f[4], nil, 0);
  321. r->accsz = strtoul(cb->f[5], nil, 0);
  322. if(r->accsz < 1 || r->accsz > 4){
  323. free(r);
  324. reg = nil;
  325. error("bad region access size");
  326. }
  327. reg = r;
  328. DBG("region %s %s %llux %llux sz%d",
  329. r->name, acpiregstr(r->spc), r->base, r->len, r->accsz);
  330. break;
  331. case CMgpe:
  332. i = strtoul(cb->f[1], nil, 0);
  333. if(i >= ngpes)
  334. error("gpe out of range");
  335. kstrdup(&gpes[i].obj, cb->f[2]);
  336. DBG("gpe %d %s\n", i, gpes[i].obj);
  337. setgpeen(i, 1);
  338. break;
  339. default:
  340. panic("acpi: unknown ctl");
  341. }
  342. poperror();
  343. free(cb);
  344. return n;
  345. #endif
  346. return -1;
  347. }
  348. Dev acpidevtab = {
  349. .dc = L'α',
  350. .name = "acpi",
  351. .reset = devreset,
  352. .init = devinit,
  353. .shutdown = devshutdown,
  354. .attach = acpiattach,
  355. .walk = acpiwalk,
  356. .stat = acpistat,
  357. .open = acpiopen,
  358. .create = devcreate,
  359. .close = acpiclose,
  360. .read = acpiread,
  361. .bread = devbread,
  362. .write = acpiwrite,
  363. .bwrite = devbwrite,
  364. .remove = devremove,
  365. .wstat = devwstat,
  366. };
  367. static int tbdf(ACPI_PCI_ID *p)
  368. {
  369. return (p->Bus << 8) | (p->Device << 3) | (p->Function);
  370. }
  371. ACPI_STATUS
  372. AcpiOsReadPciConfiguration (
  373. ACPI_PCI_ID *PciId,
  374. UINT32 Reg,
  375. UINT64 *Value,
  376. UINT32 Width)
  377. {
  378. Pcidev p;
  379. p.tbdf = tbdf(PciId);
  380. print("%s\n", __func__);
  381. switch(Width) {
  382. case 32:
  383. *Value = pcicfgr32(&p, Reg);
  384. break;
  385. case 16:
  386. *Value = pcicfgr16(&p, Reg);
  387. break;
  388. case 8:
  389. *Value = pcicfgr8(&p, Reg);
  390. break;
  391. default:
  392. panic("Can't read pci: bad width %d\n", Width);
  393. }
  394. return AE_OK;
  395. }
  396. ACPI_STATUS
  397. AcpiOsWritePciConfiguration (
  398. ACPI_PCI_ID *PciId,
  399. UINT32 Reg,
  400. UINT64 Value,
  401. UINT32 Width)
  402. {
  403. Pcidev p;
  404. p.tbdf = tbdf(PciId);
  405. print("%s\n", __func__);
  406. switch(Width) {
  407. case 32:
  408. pcicfgw32(&p, Reg, Value);
  409. break;
  410. case 16:
  411. pcicfgw16(&p, Reg, Value);
  412. break;
  413. case 8:
  414. pcicfgw8(&p, Reg, Value);
  415. break;
  416. default:
  417. panic("Can't read pci: bad width %d\n", Width);
  418. }
  419. return AE_OK;
  420. }
  421. /*
  422. * Miscellaneous
  423. */
  424. BOOLEAN
  425. AcpiOsReadable (
  426. void *Pointer,
  427. ACPI_SIZE Length)
  428. {
  429. print("%s\n", __func__);
  430. panic("%s", __func__);
  431. return AE_OK;
  432. }
  433. BOOLEAN
  434. AcpiOsWritable (
  435. void *Pointer,
  436. ACPI_SIZE Length)
  437. {
  438. print("%s\n", __func__);
  439. panic("%s", __func__);
  440. return AE_OK;
  441. }
  442. UINT64
  443. AcpiOsGetTimer (
  444. void)
  445. {
  446. print("%s\n", __func__);
  447. panic("%s", __func__);
  448. return AE_OK;
  449. }
  450. ACPI_STATUS
  451. AcpiOsSignal (
  452. UINT32 Function,
  453. void *Info)
  454. {
  455. print("%s\n", __func__);
  456. panic("%s", __func__);
  457. return AE_OK;
  458. }
  459. void ACPI_INTERNAL_VAR_XFACE
  460. AcpiOsPrintf (
  461. const char *Format,
  462. ...)
  463. {
  464. va_list args;
  465. va_start(args, Format);
  466. print((char *)Format, args);
  467. va_end(args);
  468. }
  469. void
  470. AcpiOsVprintf (
  471. const char *Format,
  472. va_list Args)
  473. {
  474. print((char *)Format, Args);
  475. }
  476. void
  477. AcpiOsFree (
  478. void * Memory)
  479. {
  480. //print("%s\n", __func__);
  481. free(Memory);
  482. }
  483. void *
  484. AcpiOsAllocate (
  485. ACPI_SIZE Size)
  486. {
  487. //print("%s\n", __func__);
  488. return malloc(Size);
  489. }
  490. void *
  491. AcpiOsMapMemory (
  492. ACPI_PHYSICAL_ADDRESS Where,
  493. ACPI_SIZE Length)
  494. {
  495. void *v = vmap(Where, Length);
  496. print("%s %p = vmap(%p,0x%x)\n", __func__, v, (void*)Where, Length);
  497. print("Val @ %p is 0x%x\n", v, *(int *)v);
  498. return v;
  499. }
  500. void
  501. AcpiOsUnmapMemory (
  502. void *LogicalAddress,
  503. ACPI_SIZE Size)
  504. {
  505. print("%s %p %d \n", __func__, LogicalAddress, Size);
  506. vunmap(LogicalAddress, Size);
  507. }
  508. ACPI_STATUS
  509. AcpiOsGetPhysicalAddress (
  510. void *LogicalAddress,
  511. ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
  512. {
  513. ACPI_PHYSICAL_ADDRESS ret = mmuphysaddr((uintptr_t)LogicalAddress);
  514. print("%s %p = mmyphysaddr(%p)", __func__, (void *)ret, LogicalAddress);
  515. *PhysicalAddress = ret;
  516. return AE_OK;
  517. }
  518. /* This is the single threaded version of
  519. * these functions. This is now NetBSD does it. */
  520. ACPI_STATUS
  521. AcpiOsCreateSemaphore (
  522. UINT32 MaxUnits,
  523. UINT32 InitialUnits,
  524. ACPI_SEMAPHORE *OutHandle)
  525. {
  526. //print("%s\n", __func__);
  527. *OutHandle = (ACPI_SEMAPHORE) 1;
  528. return AE_OK;
  529. }
  530. ACPI_STATUS
  531. AcpiOsDeleteSemaphore (
  532. ACPI_SEMAPHORE Handle)
  533. {
  534. //print("%s\n", __func__);
  535. return AE_OK;
  536. }
  537. ACPI_STATUS
  538. AcpiOsWaitSemaphore (
  539. ACPI_SEMAPHORE Handle,
  540. UINT32 Units,
  541. UINT16 Timeout)
  542. {
  543. //print("%s\n", __func__);
  544. return AE_OK;
  545. }
  546. ACPI_STATUS
  547. AcpiOsSignalSemaphore (
  548. ACPI_SEMAPHORE Handle,
  549. UINT32 Units)
  550. {
  551. //print("%s\n", __func__);
  552. return AE_OK;
  553. }
  554. /* this is the single threaded case and as minix shows there is nothing to do. */
  555. ACPI_STATUS
  556. AcpiOsCreateLock (
  557. ACPI_SPINLOCK *OutHandle)
  558. {
  559. //print("%s\n", __func__);
  560. *OutHandle = nil;
  561. return AE_OK;
  562. }
  563. void
  564. AcpiOsDeleteLock (
  565. ACPI_SPINLOCK Handle)
  566. {
  567. //print("%s\n", __func__);
  568. }
  569. ACPI_CPU_FLAGS
  570. AcpiOsAcquireLock (
  571. ACPI_SPINLOCK Handle)
  572. {
  573. //print("%s\n", __func__);
  574. return 0;
  575. }
  576. void
  577. AcpiOsReleaseLock (
  578. ACPI_SPINLOCK Handle,
  579. ACPI_CPU_FLAGS Flags)
  580. {
  581. //print("%s\n", __func__);
  582. }
  583. struct handler {
  584. ACPI_OSD_HANDLER ServiceRoutine;
  585. void *Context;
  586. };
  587. /* The ACPI interrupt signature and the Harvey one are not compatible. So, we pass an arg to
  588. * intrenable that can in turn be used to this function to call the ACPI handler. */
  589. static void acpihandler(Ureg *_, void *arg)
  590. {
  591. struct handler *h = arg;
  592. h->ServiceRoutine(h->Context);
  593. }
  594. ACPI_STATUS
  595. AcpiOsInstallInterruptHandler (
  596. UINT32 InterruptNumber,
  597. ACPI_OSD_HANDLER ServiceRoutine,
  598. void *Context)
  599. {
  600. /* minix says "don't do it". So we don't, yet. */
  601. return AE_OK;
  602. struct handler *h = malloc(sizeof(*h));
  603. if (! h)
  604. return AE_NO_MEMORY;
  605. h->ServiceRoutine = ServiceRoutine;
  606. h->Context = Context;
  607. print("%s %d %p %p \n", __func__, InterruptNumber, ServiceRoutine, Context);
  608. /* once enabled, can't be disabled; ignore the return value unless it's nil. */
  609. intrenable(InterruptNumber, acpihandler, h, 0x5, "ACPI interrupt handler");
  610. return AE_OK;
  611. }
  612. ACPI_STATUS
  613. AcpiOsRemoveInterruptHandler (
  614. UINT32 InterruptNumber,
  615. ACPI_OSD_HANDLER ServiceRoutine)
  616. {
  617. print("%s\n", __func__);
  618. panic("%s", __func__);
  619. return AE_OK;
  620. }
  621. void
  622. AcpiOsWaitEventsComplete (
  623. void)
  624. {
  625. print("%s\n", __func__);
  626. panic("%s", __func__);
  627. }
  628. void
  629. AcpiOsSleep (
  630. UINT64 Milliseconds)
  631. {
  632. print("%s\n", __func__);
  633. panic("%s", __func__);
  634. }
  635. void
  636. AcpiOsStall(
  637. UINT32 Microseconds)
  638. {
  639. print("%s\n", __func__);
  640. panic("%s", __func__);
  641. }
  642. ACPI_THREAD_ID
  643. AcpiOsGetThreadId (
  644. void)
  645. {
  646. /* What to do here? ACPI won't take 0 for an answer.
  647. * I guess tell it we're 1? What do we do? */
  648. return 1;
  649. //print("%s\n", __func__);
  650. Proc *up = externup();
  651. return up->pid;
  652. }
  653. ACPI_STATUS
  654. AcpiOsExecute (
  655. ACPI_EXECUTE_TYPE Type,
  656. ACPI_OSD_EXEC_CALLBACK Function,
  657. void *Context)
  658. {
  659. print("%s\n", __func__);
  660. panic("%s", __func__);
  661. return AE_OK;
  662. }
  663. ACPI_STATUS
  664. AcpiOsReadPort (
  665. ACPI_IO_ADDRESS Address,
  666. UINT32 *Value,
  667. UINT32 Width)
  668. {
  669. /* Ooooooookay ... ACPI specifies the IO width in *bits*. */
  670. switch(Width) {
  671. case 4*8:
  672. *Value = inl(Address);
  673. break;
  674. case 2*8:
  675. *Value = ins(Address);
  676. break;
  677. case 1*8:
  678. *Value = inb(Address);
  679. break;
  680. default:
  681. panic("%s, bad width %d", __func__, Width);
  682. break;
  683. }
  684. print("%s 0x%x 0x%x\n", __func__, Address, *Value);
  685. return AE_OK;
  686. }
  687. ACPI_STATUS
  688. AcpiOsWritePort (
  689. ACPI_IO_ADDRESS Address,
  690. UINT32 Value,
  691. UINT32 Width)
  692. {
  693. switch(Width) {
  694. case 4*8:
  695. outl(Address, Value);
  696. break;
  697. case 2*8:
  698. outs(Address, Value);
  699. break;
  700. case 1*8:
  701. outb(Address, Value);
  702. break;
  703. default:
  704. panic("%s, bad width %d", __func__, Width);
  705. break;
  706. }
  707. print("%s 0x%x 0x%x\n", __func__, Address, Value);
  708. return AE_OK;
  709. }
  710. /*
  711. * Platform and hardware-independent physical memory interfaces
  712. */
  713. ACPI_STATUS
  714. AcpiOsReadMemory (
  715. ACPI_PHYSICAL_ADDRESS Address,
  716. UINT64 *Value,
  717. UINT32 Width)
  718. {
  719. print("%s\n", __func__);
  720. panic("%s", __func__);
  721. return AE_OK;
  722. }
  723. ACPI_STATUS
  724. AcpiOsWriteMemory (
  725. ACPI_PHYSICAL_ADDRESS Address,
  726. UINT64 Value,
  727. UINT32 Width)
  728. {
  729. print("%s\n", __func__);
  730. panic("%s", __func__);
  731. return AE_OK;
  732. }
  733. /*
  734. * ACPI Table interfaces
  735. */
  736. ACPI_PHYSICAL_ADDRESS
  737. AcpiOsGetRootPointer (
  738. void)
  739. {
  740. print("%s returns %p\n", __func__, rsd);
  741. return (ACPI_PHYSICAL_ADDRESS) PADDR(rsd);
  742. }
  743. ACPI_STATUS
  744. AcpiOsPredefinedOverride (
  745. const ACPI_PREDEFINED_NAMES *InitVal,
  746. ACPI_STRING *NewVal)
  747. {
  748. print("%s\n", __func__);
  749. *NewVal = nil;
  750. return AE_OK;
  751. }
  752. ACPI_STATUS
  753. AcpiOsTableOverride (
  754. ACPI_TABLE_HEADER *ExistingTable,
  755. ACPI_TABLE_HEADER **NewTable)
  756. {
  757. print("%s\n", __func__);
  758. *NewTable = nil;
  759. return AE_OK;
  760. }
  761. ACPI_STATUS
  762. AcpiOsPhysicalTableOverride (
  763. ACPI_TABLE_HEADER *ExistingTable,
  764. ACPI_PHYSICAL_ADDRESS *NewAddress,
  765. UINT32 *NewTableLength)
  766. {
  767. print("%s\n", __func__);
  768. *NewAddress = (ACPI_PHYSICAL_ADDRESS)nil;
  769. return AE_OK;
  770. }
  771. /*
  772. * Debug input
  773. */
  774. ACPI_STATUS
  775. AcpiOsGetLine (
  776. char *Buffer,
  777. UINT32 BufferLength,
  778. UINT32 *BytesRead)
  779. {
  780. print("%s\n", __func__);
  781. panic("%s", __func__);
  782. return AE_OK;
  783. }