2 * Copyright (C) 2015 Alexander Couzens <lynxis@fe80.eu>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
16 #include <arch/acpi.h>
17 #include <arch/acpigen.h>
20 * generate_sata_ssdt_ports("\_SB.PCI0.SATA", 0x3);
22 * Scope (\_SB.PCI0.SATA)
26 * Name (_ADR, 0x0000FFFF) // _ADR: Address
31 * Name (_ADR, 0x0001FFFF) // _ADR: Address
36 void generate_sata_ssdt_ports(const char *scope
, uint32_t enable_map
)
40 char port_name
[4] = "PR00";
42 acpigen_write_scope(scope
);
44 /* generate a device for every enabled port */
45 for (i
= 0; i
< 32; i
++) {
47 if (!(bit
& enable_map
))
50 port_name
[2] = '0' + i
/ 10;
51 port_name
[3] = '0' + i
% 10;
53 acpigen_write_device(port_name
);
55 acpigen_write_name_dword("_ADR", 0xffff + i
* 0x10000);
56 acpigen_pop_len(); /* close PRT%d */
59 acpigen_pop_len(); /* close scope */