Skip to content

Commit

Permalink
Merge branch 'master' into memdisk-maxmem-for-hpa
Browse files Browse the repository at this point in the history
  • Loading branch information
geneC committed Feb 7, 2011
2 parents 3db568e + 5c93089 commit a188ebe
Show file tree
Hide file tree
Showing 72 changed files with 7,323 additions and 234 deletions.
98 changes: 98 additions & 0 deletions com32/gplinclude/acpi/acpi.h
@@ -0,0 +1,98 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2009-2011 Erwan Velu - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */

#ifndef ACPI_H
#define ACPI_H

#define DEBUG_ACPI 0

void dbg_printf(const char *fmt, ...);
#define DEBUG_PRINT(x) do { if (DEBUG_ACPI) dbg_printf x; } while (0)

#include <inttypes.h>
#include <stdbool.h>
#include <acpi/structs.h>
#include <acpi/rsdp.h>
#include <acpi/rsdt.h>
#include <acpi/xsdt.h>
#include <acpi/fadt.h>
#include <acpi/madt.h>
#include <acpi/dsdt.h>
#include <acpi/ssdt.h>
#include <acpi/sbst.h>
#include <acpi/ecdt.h>
#include <acpi/facs.h>
#include <acpi/hpet.h>
#include <acpi/tcpa.h>
#include <acpi/mcfg.h>
#include <acpi/slic.h>
#include <acpi/boot.h>

enum { ACPI_FOUND = 1, ENO_ACPI = 2 , MADT_FOUND = 3 , ENO_MADT = 4 };

#define MAX_SSDT 128

/* Some other description HEADERS : ACPI doc: 5.2.6*/
#define OEMX "OEMx"
#define SRAR "SRAT"
#define BERT "BERT"
#define BOOT "BOOT"
#define CPEP "CPEP"
#define DBGP "DGBP"
#define DMAR "DMAR"
#define ERST "ERST"
#define ETDT "ETDT"
#define HEST "HEST"
#define HPET "HPET"
#define IBFT "IBFT"
#define MCFG "MCFG"
#define SPCR "SPCR"
#define SPMI "SPMI"
#define TCPA "TCPA"
#define UEFI "UEFI"
#define WAET "WAET"
#define WDAT "WDAT"
#define WDRT "WDRT"
#define WSPT "WSPT"
#define SLIC "SLIC"

/* This macro are used to extract ACPI structures
* please be careful about the q (interator) naming */
#define cp_struct(dest) memcpy(dest,q,sizeof(*dest)); q+=sizeof(*dest)
#define cp_str_struct(dest) memcpy(dest,q,sizeof(dest)-1); dest[sizeof(dest)-1]=0;q+=sizeof(dest)-1

typedef struct {
s_rsdp rsdp;
s_rsdt rsdt;
s_xsdt xsdt;
s_fadt fadt;
s_madt madt;
s_dsdt dsdt;
s_ssdt *ssdt[MAX_SSDT];
uint8_t ssdt_count;
s_sbst sbst;
s_ecdt ecdt;
s_facs facs;
s_hpet hpet;
s_tcpa tcpa;
s_mcfg mcfg;
s_slic slic;
s_boot boot;
} s_acpi;

int parse_acpi(s_acpi * acpi);
int parse_xsdt(s_acpi * acpi);
void parse_madt(s_acpi * acpi);
int search_rsdp(s_acpi *acpi);
void get_acpi_description_header(uint8_t *q, s_acpi_description_header * adh);
bool parse_header(uint64_t *address, s_acpi *acpi);
#endif
29 changes: 29 additions & 0 deletions com32/gplinclude/acpi/boot.h
@@ -0,0 +1,29 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2009-2011 Erwan Velu - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */

#ifndef BOOT_H
#define BOOT_H
#include <inttypes.h>
#include <stdbool.h>

#define BOOT "BOOT"

enum { BOOT_TABLE_FOUND = 1 };

typedef struct {
uint64_t *address;
s_acpi_description_header header;
/* What's inside ? */
bool valid;
} s_boot;

#endif
28 changes: 28 additions & 0 deletions com32/gplinclude/acpi/dsdt.h
@@ -0,0 +1,28 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2009-2011 Erwan Velu - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */

#ifndef DSDT_H
#define DSDT_H
#include <inttypes.h>
#include <stdbool.h>

#define DSDT "DSDT"

typedef struct {
uint64_t *address;
s_acpi_description_header header;
uint8_t *definition_block;
bool valid;
} s_dsdt;

void parse_dsdt(s_dsdt *dsdt);
#endif
38 changes: 38 additions & 0 deletions com32/gplinclude/acpi/ecdt.h
@@ -0,0 +1,38 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2009-2011 Erwan Velu - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */

#ifndef ECDT_H
#define ECDT_H
#include <inttypes.h>
#include <stdbool.h>

#define ECDT "ECDT"

/* Offset of the EC_ID in the structure */
#define EC_ID_OFFSET 65

typedef struct {
uint64_t *address;
s_acpi_description_header header;
bool valid;
uint32_t warning_energy_level;
uint32_t low_energy_level;
uint32_t critical_energy_level;
s_gas ec_control;
s_gas ec_data;
uint32_t uid;
uint8_t gpe_bit;
char *ec_id;
} s_ecdt;

void parse_ecdt(s_ecdt * ecdt);
#endif
41 changes: 41 additions & 0 deletions com32/gplinclude/acpi/facs.h
@@ -0,0 +1,41 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2009 Erwan Velu - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */

#ifndef FACS_H
#define FACS_H
#include <inttypes.h>
#include <stdbool.h>

#define FACS "FACS"

/* Features Flags for "flags" */
#define S4BIOS_F 1

/* Features flags for global_lock */
#define PENDING 1
#define OWNED 1<<1

typedef struct {
uint64_t *address;
uint8_t signature[4+1];
uint8_t length;
uint32_t hardware_signature;
uint32_t firmware_waking_vector;
uint32_t global_lock;
uint32_t flags;
uint64_t x_firmware_waking_vector;
uint8_t version;
bool valid;
} s_facs;

void parse_facs(s_facs *facs);
#endif
121 changes: 121 additions & 0 deletions com32/gplinclude/acpi/fadt.h
@@ -0,0 +1,121 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2009-2011 Erwan Velu - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */

#ifndef FADT_H
#define FADT_H
#include <inttypes.h>
#include <stdbool.h>

enum { FADT_TABLE_FOUND = 1};

#define FACP "FACP"
#define FADT "FADT"

/* prefered pm profiles */
enum { PM_UNSPECIFIED = 0,
PM_DESKTOP = 1,
PM_MOBILE = 2,
PM_WORKSTATION = 3,
PM_ENTERPRISE_SERVER = 4,
PM_SOHO_SERVER = 5,
PM_APPLIANCE_PC = 6,
PM_PERFORMANCE_SERVER = 7
};

/* iapc_boot_arch flags*/
#define IAPC_LEGAGY_DEVICE 1
#define IAPC_8042 1<<1
#define IAPC_VGA_NOT_PRESENT 1<<2
#define IAPC_MSI_NOT_SUPPORTED 1<<3
#define IAPC_PCIE_ASPM_CONTROLS 1<<4

/* feature flags for "flags" */
#define WBINVD 1
#define WBINVD_FLUSH 1<<1
#define PROC_C1 1<<2
#define P_LVL2_UP 1<<3
#define PWR_BUTTON 1<<4
#define SLP_BUTTON 1<<5
#define FIX_RTC 1<<6
#define RTC_S4 1<<7
#define TMR_VAL_EXT 1<<8
#define DCK_CAP 1<<9
#define RESET_REG_SUP 1<<10
#define SEALED_CASE 1<<11
#define HEADLESS 1<<12
#define CPU_SW_SLP 1<<13
#define PCI_EXP_WAK 1<<14
#define USE_PLATEFORM_CLOCK 1<<15
#define S4_RTC_STS_VALID 1<<16
#define REMOTE_POWER_ON_CAPABLE 1<<17
#define FORCE_APIC_CLUSTER_MODEL 1<<18
#define FORCE_APIC_PHYSICAL_DESTINATION_MODE 1<<19

typedef struct {
uint64_t *address;
s_acpi_description_header header;
bool valid;
uint32_t *firmware_ctrl;
uint32_t *dsdt_address;
uint8_t reserved;
uint8_t prefered_pm_profile;
uint16_t sci_int;
uint32_t smi_cmd;
uint8_t acpi_enable;
uint8_t acpi_disable;
uint8_t s4bios_req;
uint8_t pstate_cnt;
uint32_t pm1a_evt_blk;
uint32_t pm1b_evt_blk;
uint32_t pm1a_cnt_blk;
uint32_t pm1b_cnt_blk;
uint32_t pm2_cnt_blk;
uint32_t pm_tmr_blk;
uint32_t gpe0_blk;
uint32_t gpe1_blk;
uint8_t pm1_evt_len;
uint8_t pm1_cnt_len;
uint8_t pm2_cnt_len;
uint8_t pm_tmr_len;
uint8_t gpe0_blk_len;
uint8_t gpe1_blk_len;
uint8_t gpe1_base;
uint8_t cst_cnt;
uint16_t p_lvl2_lat;
uint16_t p_lvl3_lat;
uint16_t flush_size;
uint16_t flush_stride;
uint8_t duty_offset;
uint8_t duty_width;
uint8_t day_alarm;
uint8_t mon_alarm;
uint8_t century;
uint16_t iapc_boot_arch;
uint8_t reserved_2;
uint32_t flags;
s_gas reset_reg;
uint8_t reset_value;
uint8_t reserved_3[3];
uint64_t *x_firmware_ctrl;
uint64_t *x_dsdt;
s_gas x_pm1a_evt_blk;
s_gas x_pm1b_evt_blk;
s_gas x_pm1a_cnt_blk;
s_gas x_pm1b_cnt_blk;
s_gas x_pm2_cnt_blk;
s_gas x_pm_tmr_blk;
s_gas x_gpe0_blk;
s_gas x_gpe1_blk;
} s_fadt;

void parse_fadt(s_fadt * fadt);
#endif
29 changes: 29 additions & 0 deletions com32/gplinclude/acpi/hpet.h
@@ -0,0 +1,29 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2009-2011 Erwan Velu - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */

#ifndef HPET_H
#define HPET_H
#include <inttypes.h>
#include <stdbool.h>

#define HPET "HPET"

enum { HPET_TABLE_FOUND = 1 };

typedef struct {
uint64_t *address;
s_acpi_description_header header;
/* What's inside ? */
bool valid;
} s_hpet;

#endif

0 comments on commit a188ebe

Please sign in to comment.