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.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
20 #include <arch/acpi.h>
21 #include <arch/acpigen.h>
24 * generate_sata_ssdt_ports("\_SB.PCI0.SATA", 0x3);
26 * Scope (\_SB.PCI0.SATA)
30 * Name (_ADR, 0x0000FFFF) // _ADR: Address
35 * Name (_ADR, 0x0001FFFF) // _ADR: Address
40 void generate_sata_ssdt_ports(const char *scope
, uint32_t enable_map
)
44 char port_name
[4] = "PR00";
46 acpigen_write_scope(scope
);
48 /* generate a device for every enabled port */
49 for (i
= 0; i
< 32; i
++) {
51 if (!(bit
& enable_map
))
54 port_name
[2] = '0' + i
/ 10;
55 port_name
[3] = '0' + i
% 10;
57 acpigen_write_device(port_name
);
59 acpigen_write_name_dword("_ADR", 0xffff + i
* 0x10000);
60 acpigen_pop_len(); /* close PRT%d */
63 acpigen_pop_len(); /* close scope */