hc
2025-02-14 bbb9540dc49f70f6b703d1c8d1b85fa5f602d86e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * Copyright(c) 2009 Intel Corporation. All rights reserved.
 *
 * SPDX-License-Identifier:    GPL-2.0+    BSD-3-Clause
 */
 
#ifndef _LINUX_SFI_H
#define _LINUX_SFI_H
 
#include <errno.h>
#include <linux/types.h>
 
/* Table signatures reserved by the SFI specification */
#define SFI_SIG_SYST        "SYST"
#define SFI_SIG_FREQ        "FREQ"
#define SFI_SIG_CPUS        "CPUS"
#define SFI_SIG_MTMR        "MTMR"
#define SFI_SIG_MRTC        "MRTC"
#define SFI_SIG_MMAP        "MMAP"
#define SFI_SIG_APIC        "APIC"
#define SFI_SIG_XSDT        "XSDT"
#define SFI_SIG_WAKE        "WAKE"
#define SFI_SIG_DEVS        "DEVS"
#define SFI_SIG_GPIO        "GPIO"
 
#define SFI_SIGNATURE_SIZE    4
#define SFI_OEM_ID_SIZE        6
#define SFI_OEM_TABLE_ID_SIZE    8
 
#define SFI_NAME_LEN        16
#define SFI_TABLE_MAX_ENTRIES    16
 
#define SFI_GET_NUM_ENTRIES(ptable, entry_type) \
   ((ptable->header.len - sizeof(struct sfi_table_header)) / \
   (sizeof(entry_type)))
/*
 * Table structures must be byte-packed to match the SFI specification,
 * as they are provided by the BIOS.
 */
struct __packed sfi_table_header {
   char    sig[SFI_SIGNATURE_SIZE];
   u32    len;
   u8    rev;
   u8    csum;
   char    oem_id[SFI_OEM_ID_SIZE];
   char    oem_table_id[SFI_OEM_TABLE_ID_SIZE];
};
 
struct __packed sfi_table_simple {
   struct sfi_table_header        header;
   u64                pentry[1];
};
 
/* Comply with UEFI spec 2.1 */
struct __packed sfi_mem_entry {
   u32    type;
   u64    phys_start;
   u64    virt_start;
   u64    pages;
   u64    attrib;
};
 
/* Memory type definitions */
enum sfi_mem_type {
   SFI_MEM_RESERVED,
   SFI_LOADER_CODE,
   SFI_LOADER_DATA,
   SFI_BOOT_SERVICE_CODE,
   SFI_BOOT_SERVICE_DATA,
   SFI_RUNTIME_SERVICE_CODE,
   SFI_RUNTIME_SERVICE_DATA,
   SFI_MEM_CONV,
   SFI_MEM_UNUSABLE,
   SFI_ACPI_RECLAIM,
   SFI_ACPI_NVS,
   SFI_MEM_MMIO,
   SFI_MEM_IOPORT,
   SFI_PAL_CODE,
   SFI_MEM_TYPEMAX,
};
 
struct __packed sfi_cpu_table_entry {
   u32    apic_id;
};
 
struct __packed sfi_cstate_table_entry {
   u32    hint;        /* MWAIT hint */
   u32    latency;    /* latency in ms */
};
 
struct __packed sfi_apic_table_entry {
   u64    phys_addr;    /* phy base addr for APIC reg */
};
 
struct __packed sfi_freq_table_entry {
   u32    freq_mhz;    /* in MHZ */
   u32    latency;    /* transition latency in ms */
   u32    ctrl_val;    /* value to write to PERF_CTL */
};
 
struct __packed sfi_wake_table_entry {
   u64    phys_addr;    /* pointer to where the wake vector locates */
};
 
struct __packed sfi_timer_table_entry {
   u64    phys_addr;    /* phy base addr for the timer */
   u32    freq_hz;    /* in HZ */
   u32    irq;
};
 
struct __packed sfi_rtc_table_entry {
   u64    phys_addr;    /* phy base addr for the RTC */
   u32    irq;
};
 
struct __packed sfi_device_table_entry {
   u8    type;        /* bus type, I2C, SPI or ...*/
   u8    host_num;    /* attached to host 0, 1...*/
   u16    addr;
   u8    irq;
   u32    max_freq;
   char    name[SFI_NAME_LEN];
};
 
enum {
   SFI_DEV_TYPE_SPI    = 0,
   SFI_DEV_TYPE_I2C,
   SFI_DEV_TYPE_UART,
   SFI_DEV_TYPE_HSI,
   SFI_DEV_TYPE_IPC,
   SFI_DEV_TYPE_SD,
};
 
struct __packed sfi_gpio_table_entry {
   char    controller_name[SFI_NAME_LEN];
   u16    pin_no;
   char    pin_name[SFI_NAME_LEN];
};
 
struct sfi_xsdt_header {
   uint32_t oem_revision;
   uint32_t creator_id;
   uint32_t creator_revision;
};
 
typedef int (*sfi_table_handler) (struct sfi_table_header *table);
 
/**
 * write_sfi_table() - Write Simple Firmware Interface tables
 *
 * @base:    Address to write table to
 * @return address to use for the next table
 */
ulong write_sfi_table(ulong base);
 
#endif /*_LINUX_SFI_H */