coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#include <types.h>
4
#include <
device/device.h
>
5
#include <
device/pci_def.h
>
6
#include <
console/console.h
>
7
#if CONFIG(VGA_ROM_RUN)
8
#include <
x86emu/x86emu.h
>
9
#endif
10
#include <
option.h
>
11
#include <
arch/interrupt.h
>
12
#include <
southbridge/intel/bd82x6x/pch.h
>
13
14
#if CONFIG(VGA_ROM_RUN)
15
static
int
int15_handler
(
void
)
16
{
17
int
res = 0;
18
19
printk
(
BIOS_DEBUG
,
"%s: AX=%04x BX=%04x CX=%04x DX=%04x\n"
,
20
__func__,
X86_AX
,
X86_BX
,
X86_CX
,
X86_DX
);
21
22
switch
(
X86_EAX
& 0xffff) {
23
case
0x5f34:
24
/*
25
* Set Panel Fitting Hook:
26
* bit 2 = Graphics Stretching
27
* bit 1 = Text Stretching
28
* bit 0 = Centering (do not set with bit1 or bit2)
29
* 0 = video BIOS default
30
*/
31
X86_EAX
&= 0xffff0000;
32
X86_EAX
|= 0x005f;
33
X86_ECX
&= 0xffffff00;
34
X86_ECX
|= 0x00;
/* Use video BIOS default */
35
res = 1;
36
break
;
37
case
0x5f35:
38
/*
39
* Boot Display Device Hook:
40
* bit 0 = CRT
41
* bit 1 = TV (eDP)
42
* bit 2 = EFP
43
* bit 3 = LFP
44
* bit 4 = CRT2
45
* bit 5 = TV2 (eDP)
46
* bit 6 = EFP2
47
* bit 7 = LFP2
48
*/
49
X86_EAX
&= 0xffff0000;
50
X86_EAX
|= 0x005f;
51
X86_ECX
&= 0xffff0000;
52
X86_ECX
|= 0x0000;
/* Use video BIOS default */
53
res = 1;
54
break
;
55
case
0x5f51:
56
/*
57
* Hook to select active LFP configuration:
58
* 00h = No LVDS, VBIOS does not enable LVDS
59
* 01h = Int-LVDS, LFP driven by integrated LVDS decoder
60
* 02h = SDVO-LVDS, LFP driven by SDVO decoder
61
* 03h = eDP, LFP Driven by Int-DisplayPort encoder
62
*/
63
X86_EAX
&= 0xffff0000;
64
X86_EAX
|= 0x005f;
65
X86_ECX
&= 0xffff0000;
66
X86_ECX
|= 0x0000;
/* TODO: Make this configurable in NVRAM? */
67
res = 1;
68
break
;
69
case
0x5f40:
70
/*
71
* Boot Panel Type Hook:
72
* BL(in): 00h = LFP, 01h = LFP2
73
* CL(out): panel type id in table: 1..16
74
*/
75
if
(0 == (
X86_EBX
& 0xff)) {
76
X86_EAX
&= 0xffff0000;
77
X86_EAX
|= 0x015f;
78
res = 1;
79
}
else
if
(1 == (
X86_EBX
& 0xff)) {
80
X86_EAX
&= 0xffff0000;
81
X86_EAX
|= 0x015f;
82
res = 1;
83
}
else
{
84
printk
(
BIOS_DEBUG
,
85
"Unknown panel index %u "
86
"in INT15 function %04x!\n"
,
87
X86_EBX
& 0xff,
X86_EAX
& 0xffff);
88
}
89
break
;
90
case
0x5f52:
91
/*
92
* Panel Color Depth:
93
* 00h = 18 bit
94
* 01h = 24 bit
95
*/
96
X86_EAX
&= 0xffff0000;
97
X86_EAX
|= 0x005f;
98
X86_ECX
&= 0xffff0000;
99
X86_ECX
|= 0x0001;
100
res = 1;
101
break
;
102
case
0x5f14:
103
if
((
X86_EBX
& 0xffff) == 0x78f) {
104
/*
105
* Get Miscellaneous Status Hook:
106
* bit 2: AC power active?
107
* bit 1: lid closed?
108
* bit 0: docked?
109
*/
110
X86_EAX
&= 0xffff0000;
111
X86_EAX
|= 0x015f;
112
res = 1;
113
}
else
{
114
printk
(
BIOS_DEBUG
,
115
"Unknown BX 0x%04x in INT15 function %04x!\n"
,
116
X86_EBX
& 0xffff,
X86_EAX
& 0xffff);
117
}
118
break
;
119
case
0x5f49:
120
/*
121
* Get Inverter Type and Polarity:
122
* EBX: backlight control brightness: 0..255
123
* ECX:
124
* 0 = Enable PWM inverted, 2 = Enable PWM
125
* 1 = Enable I2C inverted, 3 = Enable I2C
126
*/
127
X86_EAX
&= 0xffff0000;
128
X86_EAX
|= 0x015f;
129
res = 1;
130
break
;
131
default
:
132
printk
(
BIOS_DEBUG
,
"Unknown INT15 function %04x!\n"
,
133
X86_EAX
& 0xffff);
134
break
;
135
}
136
return
res;
137
}
138
#endif
139
140
141
142
/* mainboard_enable is executed as first thing after */
143
/* enumerate_buses(). */
144
145
static
void
mainboard_enable
(
struct
device
*dev)
146
{
147
#if CONFIG(PCI_OPTION_ROM_RUN_YABEL) || \
148
CONFIG(PCI_OPTION_ROM_RUN_REALMODE)
149
/* Install custom int15 handler for VGA OPROM */
150
mainboard_interrupt_handlers
(0x15, &
int15_handler
);
151
#endif
152
unsigned
int
disable =
get_uint_option
(
"ethernet1"
, 0);
153
if
(disable) {
154
struct
device
*nic =
pcidev_on_root
(0x1c, 2);
155
if
(nic) {
156
printk
(
BIOS_DEBUG
,
"DISABLE FIRST NIC!\n"
);
157
nic->
enabled
= 0;
158
}
159
}
160
disable =
get_uint_option
(
"ethernet2"
, 0);
161
if
(disable) {
162
struct
device
*nic =
pcidev_on_root
(0x1c, 3);
163
if
(nic) {
164
printk
(
BIOS_DEBUG
,
"DISABLE SECOND NIC!\n"
);
165
nic->
enabled
= 0;
166
}
167
}
168
}
169
170
struct
chip_operations
mainboard_ops
= {
171
.
enable_dev
=
mainboard_enable
,
172
};
mainboard_ops
struct chip_operations mainboard_ops
Definition:
mainboard.c:19
interrupt.h
mainboard_interrupt_handlers
static void mainboard_interrupt_handlers(int intXX, int(*intXX_func)(void))
Definition:
interrupt.h:14
printk
#define printk(level,...)
Definition:
stdlib.h:16
console.h
pcidev_on_root
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition:
device_const.c:260
device.h
mainboard_enable
static void mainboard_enable(struct device *dev)
Definition:
mainboard.c:145
BIOS_DEBUG
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition:
loglevel.h:128
get_uint_option
unsigned int get_uint_option(const char *name, const unsigned int fallback)
Definition:
option.c:116
option.h
pci_def.h
X86_CX
#define X86_CX
Definition:
regs.h:343
X86_ECX
#define X86_ECX
Definition:
regs.h:331
X86_EAX
#define X86_EAX
Definition:
regs.h:329
X86_BX
#define X86_BX
Definition:
regs.h:342
X86_EBX
#define X86_EBX
Definition:
regs.h:330
X86_AX
#define X86_AX
Definition:
regs.h:341
X86_DX
#define X86_DX
Definition:
regs.h:344
int15_handler
static int int15_handler(void)
Definition:
int15.c:8
pch.h
chip_operations
Definition:
device.h:23
chip_operations::enable_dev
void(* enable_dev)(struct device *dev)
Definition:
device.h:24
device
Definition:
device.h:107
device::enabled
unsigned int enabled
Definition:
device.h:122
x86emu.h
src
mainboard
kontron
ktqm77
mainboard.c
Generated by
1.9.1