Files
system76-coreboot/src/acpi/sata.c
Martin Roth 669e155ad2 AUTHORS: Move src/acpi copyrights into AUTHORS file
As discussed on the mailing list and voted upon, the coreboot project
is going to move the majority of copyrights out of the headers and into
an AUTHORS file.  This will happen a bit at a time, as we'll be unifying
license headers at the same time.

Signed-off-by: Martin Roth <martin@coreboot.org>
Change-Id: Id3382d19088cba2703350339b0bd0cfb3c0e63b2
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34604
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2019-07-30 11:04:14 +00:00

61 lines
1.4 KiB
C

/*
* This file is part of the coreboot project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "sata.h"
#include <arch/acpi.h>
#include <arch/acpigen.h>
/* e.g.
* generate_sata_ssdt_ports("\_SB.PCI0.SATA", 0x3);
* generates:
* Scope (\_SB.PCI0.SATA)
* {
* Device (PR00)
* {
* Name (_ADR, 0x0000FFFF) // _ADR: Address
* }
*
* Device (PR01)
* {
* Name (_ADR, 0x0001FFFF) // _ADR: Address
* }
* }
*
*/
void generate_sata_ssdt_ports(const char *scope, uint32_t enable_map)
{
int i;
uint32_t bit;
char port_name[4] = "PR00";
acpigen_write_scope(scope);
/* generate a device for every enabled port */
for (i = 0; i < 32; i++) {
bit = 1 << i;
if (!(bit & enable_map))
continue;
port_name[2] = '0' + i / 10;
port_name[3] = '0' + i % 10;
acpigen_write_device(port_name);
acpigen_write_name_dword("_ADR", 0xffff + i * 0x10000);
acpigen_pop_len(); /* close PRT%d */
}
acpigen_pop_len(); /* close scope */
}