IsaAcpi.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /** @file
  2. ISA ACPI Protocol Implementation
  3. Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "PcatIsaAcpi.h"
  7. //
  8. // Platform specific data for the ISA devices that are present.in the platform
  9. //
  10. //
  11. // COM 1 UART Controller
  12. //
  13. GLOBAL_REMOVE_IF_UNREFERENCED
  14. EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiCom1DeviceResources[] = {
  15. {EfiIsaAcpiResourceIo, 0, 0x3f8, 0x3ff},
  16. {EfiIsaAcpiResourceInterrupt, 0, 4, 0},
  17. {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
  18. };
  19. //
  20. // COM 2 UART Controller
  21. //
  22. GLOBAL_REMOVE_IF_UNREFERENCED
  23. EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiCom2DeviceResources[] = {
  24. {EfiIsaAcpiResourceIo, 0, 0x2f8, 0x2ff},
  25. {EfiIsaAcpiResourceInterrupt, 0, 3, 0},
  26. {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
  27. };
  28. //
  29. // PS/2 Keyboard Controller
  30. //
  31. GLOBAL_REMOVE_IF_UNREFERENCED
  32. EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiPs2KeyboardDeviceResources[] = {
  33. {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},
  34. {EfiIsaAcpiResourceInterrupt, 0, 1, 0},
  35. {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
  36. };
  37. //
  38. // PS/2 Mouse Controller
  39. //
  40. GLOBAL_REMOVE_IF_UNREFERENCED
  41. EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiPs2MouseDeviceResources[] = {
  42. {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},
  43. {EfiIsaAcpiResourceInterrupt, 0, 12, 0},
  44. {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
  45. };
  46. //
  47. // Floppy Disk Controller
  48. //
  49. GLOBAL_REMOVE_IF_UNREFERENCED
  50. EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiFloppyResources[] = {
  51. {EfiIsaAcpiResourceIo, 0, 0x3f0, 0x3f7},
  52. {EfiIsaAcpiResourceInterrupt, 0, 6, 0},
  53. {EfiIsaAcpiResourceDma, EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE | EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8 | EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE, 2, 0},
  54. {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
  55. };
  56. GLOBAL_REMOVE_IF_UNREFERENCED
  57. EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiCom1Device = {
  58. {EISA_PNP_ID(0x501), 0}, mPcatIsaAcpiCom1DeviceResources
  59. }; // COM 1 UART Controller
  60. GLOBAL_REMOVE_IF_UNREFERENCED
  61. EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiCom2Device = {
  62. {EISA_PNP_ID(0x501), 1}, mPcatIsaAcpiCom2DeviceResources
  63. }; // COM 2 UART Controller
  64. GLOBAL_REMOVE_IF_UNREFERENCED
  65. EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiPs2KeyboardDevice = {
  66. {EISA_PNP_ID(0x303), 0}, mPcatIsaAcpiPs2KeyboardDeviceResources
  67. }; // PS/2 Keyboard Controller
  68. GLOBAL_REMOVE_IF_UNREFERENCED
  69. EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiPs2MouseDevice = {
  70. {EISA_PNP_ID(0x303), 1}, mPcatIsaAcpiPs2MouseDeviceResources
  71. }; // PS/2 Mouse Controller
  72. GLOBAL_REMOVE_IF_UNREFERENCED
  73. EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiFloppyADevice = {
  74. {EISA_PNP_ID(0x604), 0}, mPcatIsaAcpiFloppyResources
  75. }; // Floppy Disk Controller A:
  76. GLOBAL_REMOVE_IF_UNREFERENCED
  77. EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiFloppyBDevice = {
  78. {EISA_PNP_ID(0x604), 1}, mPcatIsaAcpiFloppyResources
  79. }; // Floppy Disk Controller B:
  80. //
  81. // Table of ISA Controllers
  82. //
  83. EFI_ISA_ACPI_RESOURCE_LIST gPcatIsaAcpiDeviceList[7] = {{{0, 0}, NULL}};
  84. /**
  85. Initialize gPcatIsaAcpiDeviceList.
  86. **/
  87. VOID
  88. InitializePcatIsaAcpiDeviceList (
  89. VOID
  90. )
  91. {
  92. UINTN Index;
  93. Index = 0;
  94. if (PcdGetBool (PcdIsaAcpiCom1Enable)) {
  95. CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiCom1Device, sizeof(mPcatIsaAcpiCom1Device));
  96. Index++;
  97. }
  98. if (PcdGetBool (PcdIsaAcpiCom2Enable)) {
  99. CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiCom2Device, sizeof(mPcatIsaAcpiCom2Device));
  100. Index++;
  101. }
  102. if (PcdGetBool (PcdIsaAcpiPs2KeyboardEnable)) {
  103. CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiPs2KeyboardDevice, sizeof(mPcatIsaAcpiPs2KeyboardDevice));
  104. Index++;
  105. }
  106. if (PcdGetBool (PcdIsaAcpiPs2MouseEnable)) {
  107. CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiPs2MouseDevice, sizeof(mPcatIsaAcpiPs2MouseDevice));
  108. Index++;
  109. }
  110. if (PcdGetBool (PcdIsaAcpiFloppyAEnable)) {
  111. CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiFloppyADevice, sizeof(mPcatIsaAcpiFloppyADevice));
  112. Index++;
  113. }
  114. if (PcdGetBool (PcdIsaAcpiFloppyBEnable)) {
  115. CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiFloppyBDevice, sizeof(mPcatIsaAcpiFloppyBDevice));
  116. Index++;
  117. }
  118. }
  119. //
  120. // ISA ACPI Protocol Functions
  121. //
  122. /**
  123. Enumerate the ISA devices on the ISA bus.
  124. @param Device Point to device ID instance
  125. @param IsaAcpiDevice On return, point to resource data for Isa device
  126. @param NextIsaAcpiDevice On return, point to resource data for next Isa device
  127. **/
  128. VOID
  129. IsaDeviceLookup (
  130. IN EFI_ISA_ACPI_DEVICE_ID *Device,
  131. OUT EFI_ISA_ACPI_RESOURCE_LIST **IsaAcpiDevice,
  132. OUT EFI_ISA_ACPI_RESOURCE_LIST **NextIsaAcpiDevice
  133. )
  134. {
  135. UINTN Index;
  136. *IsaAcpiDevice = NULL;
  137. if (NextIsaAcpiDevice != NULL) {
  138. *NextIsaAcpiDevice = NULL;
  139. }
  140. if (Device == NULL) {
  141. Index = 0;
  142. } else {
  143. for(Index = 0; gPcatIsaAcpiDeviceList[Index].ResourceItem != NULL; Index++) {
  144. if (Device->HID == gPcatIsaAcpiDeviceList[Index].Device.HID &&
  145. Device->UID == gPcatIsaAcpiDeviceList[Index].Device.UID ) {
  146. break;
  147. }
  148. }
  149. if (gPcatIsaAcpiDeviceList[Index].ResourceItem == NULL) {
  150. return;
  151. }
  152. *IsaAcpiDevice = &(gPcatIsaAcpiDeviceList[Index]);
  153. Index++;
  154. }
  155. if (gPcatIsaAcpiDeviceList[Index].ResourceItem != NULL && NextIsaAcpiDevice != NULL) {
  156. *NextIsaAcpiDevice = &(gPcatIsaAcpiDeviceList[Index]);
  157. }
  158. }
  159. /**
  160. Enumerate the ISA devices on the ISA bus
  161. @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
  162. @param Device Point to device ID instance
  163. @retval EFI_NOT_FOUND Can not found the next Isa device.
  164. @retval EFI_SUCCESS Success retrieve the next Isa device for enumration.
  165. **/
  166. EFI_STATUS
  167. EFIAPI
  168. IsaDeviceEnumerate (
  169. IN EFI_ISA_ACPI_PROTOCOL *This,
  170. OUT EFI_ISA_ACPI_DEVICE_ID **Device
  171. )
  172. {
  173. EFI_ISA_ACPI_RESOURCE_LIST *IsaAcpiDevice;
  174. EFI_ISA_ACPI_RESOURCE_LIST *NextIsaAcpiDevice;
  175. IsaDeviceLookup (*Device, &IsaAcpiDevice, &NextIsaAcpiDevice);
  176. if (NextIsaAcpiDevice == NULL) {
  177. return EFI_NOT_FOUND;
  178. }
  179. *Device = &(NextIsaAcpiDevice->Device);
  180. return EFI_SUCCESS;
  181. }
  182. /**
  183. Set ISA device power
  184. @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
  185. @param Device Point to device ID instance
  186. @param OnOff TRUE for setting isa device power on,
  187. FALSE for setting isa device power off
  188. @return EFI_SUCCESS Success to change power status for isa device.
  189. **/
  190. EFI_STATUS
  191. EFIAPI
  192. IsaDeviceSetPower (
  193. IN EFI_ISA_ACPI_PROTOCOL *This,
  194. IN EFI_ISA_ACPI_DEVICE_ID *Device,
  195. IN BOOLEAN OnOff
  196. )
  197. {
  198. return EFI_SUCCESS;
  199. }
  200. /**
  201. Get current resource for the specific ISA device.
  202. @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
  203. @param Device Point to device ID instance
  204. @param ResourceList On return, point to resources instances for given isa device
  205. @retval EFI_NOT_FOUND Can not found the resource instance for given isa device
  206. @retval EFI_SUCCESS Success to get resource instance for given isa device.
  207. **/
  208. EFI_STATUS
  209. EFIAPI
  210. IsaGetCurrentResource (
  211. IN EFI_ISA_ACPI_PROTOCOL *This,
  212. IN EFI_ISA_ACPI_DEVICE_ID *Device,
  213. OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
  214. )
  215. {
  216. IsaDeviceLookup (Device, ResourceList, NULL);
  217. if (*ResourceList == NULL) {
  218. return EFI_NOT_FOUND;
  219. }
  220. return EFI_SUCCESS;
  221. }
  222. /**
  223. Get possible resource for the specific ISA device.
  224. @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
  225. @param Device Point to device ID instance
  226. @param ResourceList On return, point to resources instances for given isa device
  227. @retval EFI_SUCCESS Success to get resource instance for given isa device.
  228. **/
  229. EFI_STATUS
  230. EFIAPI
  231. IsaGetPossibleResource (
  232. IN EFI_ISA_ACPI_PROTOCOL *This,
  233. IN EFI_ISA_ACPI_DEVICE_ID *Device,
  234. OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
  235. )
  236. {
  237. return EFI_SUCCESS;
  238. }
  239. /**
  240. Set resource for the specific ISA device.
  241. @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
  242. @param Device Point to device ID instance
  243. @param ResourceList Point to resources instances for given isa device
  244. @return EFI_SUCCESS Success to set resource.
  245. **/
  246. EFI_STATUS
  247. EFIAPI
  248. IsaSetResource (
  249. IN EFI_ISA_ACPI_PROTOCOL *This,
  250. IN EFI_ISA_ACPI_DEVICE_ID *Device,
  251. IN EFI_ISA_ACPI_RESOURCE_LIST *ResourceList
  252. )
  253. {
  254. return EFI_SUCCESS;
  255. }
  256. /**
  257. Enable/Disable the specific ISA device.
  258. @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
  259. @param Device Point to device ID instance
  260. @param Enable Enable/Disable
  261. @return EFI_SUCCESS Success to enable/disable.
  262. **/
  263. EFI_STATUS
  264. EFIAPI
  265. IsaEnableDevice (
  266. IN EFI_ISA_ACPI_PROTOCOL *This,
  267. IN EFI_ISA_ACPI_DEVICE_ID *Device,
  268. IN BOOLEAN Enable
  269. )
  270. {
  271. return EFI_SUCCESS;
  272. }
  273. /**
  274. Initialize the specific ISA device.
  275. @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
  276. @param Device Point to device ID instance
  277. @return EFI_SUCCESS Success to initialize.
  278. **/
  279. EFI_STATUS
  280. EFIAPI
  281. IsaInitDevice (
  282. IN EFI_ISA_ACPI_PROTOCOL *This,
  283. IN EFI_ISA_ACPI_DEVICE_ID *Device
  284. )
  285. {
  286. return EFI_SUCCESS;
  287. }
  288. /**
  289. Initialize the ISA interface.
  290. @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
  291. @return EFI_SUCCESS Success to initialize ISA interface.
  292. **/
  293. EFI_STATUS
  294. EFIAPI
  295. IsaInterfaceInit (
  296. IN EFI_ISA_ACPI_PROTOCOL *This
  297. )
  298. {
  299. return EFI_SUCCESS;
  300. }