Skip to content

Commit 2c3a054

Browse files
committed
WIP
1 parent b8eda96 commit 2c3a054

File tree

16 files changed

+288
-17
lines changed

16 files changed

+288
-17
lines changed

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ case "$target_cpu"-"$platform" in
167167
mipsel-fuloong) platform=loongson ;;
168168
mipsel-loongson) ;;
169169
arm-uboot) ;;
170+
arm-coreboot) ;;
170171
arm-efi) ;;
171172
arm64-efi) ;;
172173
*-emu) ;;

gentpl.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ]
5454
GROUPS["uboot"] = [ "arm_uboot" ]
5555
GROUPS["xen"] = [ "i386_xen", "x86_64_xen" ]
56+
GROUPS["coreboot"] = [ "i386_coreboot", "arm_coreboot" ]
5657

5758
# emu is a special case so many core functionality isn't needed on this platform
5859
GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu")
@@ -65,7 +66,7 @@
6566
GROUPS["usb"] = GROUPS["pci"]
6667

6768
# If gfxterm is main output console integrate it into kernel
68-
GROUPS["videoinkernel"] = ["mips_loongson", "i386_coreboot" ]
69+
GROUPS["videoinkernel"] = ["mips_loongson", "i386_coreboot", "arm_coreboot" ]
6970
GROUPS["videomodules"] = GRUB_PLATFORMS[:];
7071
for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i)
7172

@@ -75,7 +76,7 @@
7576
for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
7677

7778
# Flattened Device Trees (FDT)
78-
GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ]
79+
GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi", "arm_coreboot" ]
7980

8081
# Needs software helpers for division
8182
# Must match GRUB_DIVISION_IN_SOFTWARE in misc.h

grub-core/Makefile.am

+10-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ endif
112112

113113
if COND_i386_coreboot
114114
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
115-
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/coreboot/lbio.h
115+
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/coreboot/lbio.h
116116
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
117117
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
118118
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
@@ -239,6 +239,15 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
239239
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
240240
endif
241241

242+
if COND_arm_coreboot
243+
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
244+
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
245+
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
246+
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
247+
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
248+
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
249+
endif
250+
242251
if COND_arm_efi
243252
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h
244253
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h

grub-core/Makefile.core.def

+17-6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ kernel = {
9292
emu_cppflags = '$(CPPFLAGS_GNULIB)';
9393
arm_uboot_ldflags = '-Wl,-r,-d';
9494
arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
95+
arm_coreboot_ldflags = '-Wl,-r,-d';
96+
arm_coreboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
9597

9698
i386_pc_startup = kern/i386/pc/startup.S;
9799
i386_efi_startup = kern/i386/efi/startup.S;
@@ -105,7 +107,8 @@ kernel = {
105107
mips_startup = kern/mips/startup.S;
106108
sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S;
107109
powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
108-
arm_uboot_startup = kern/arm/uboot/startup.S;
110+
arm_uboot_startup = kern/arm/startup.S;
111+
arm_coreboot_startup = kern/arm/startup.S;
109112
arm_efi_startup = kern/arm/efi/startup.S;
110113
arm64_efi_startup = kern/arm64/efi/startup.S;
111114

@@ -149,6 +152,11 @@ kernel = {
149152
uboot = kern/uboot/init.c;
150153
uboot = kern/uboot/hw.c;
151154
uboot = term/uboot/console.c;
155+
arm_uboot = kern/arm/uboot/init.c;
156+
arm_uboot = kern/arm/uboot/uboot.S;
157+
158+
arm_coreboot = kern/arm/coreboot/init.c;
159+
arm_coreboot = kern/arm/coreboot/coreboot.S;
152160

153161
terminfoinkernel = term/terminfo.c;
154162
terminfoinkernel = term/tparm.c;
@@ -223,8 +231,9 @@ kernel = {
223231
i386_qemu = kern/vga_init.c;
224232
i386_qemu = kern/i386/qemu/mmap.c;
225233

226-
i386_coreboot = kern/i386/coreboot/mmap.c;
234+
coreboot = kern/coreboot/mmap.c;
227235
i386_coreboot = kern/i386/coreboot/cbtable.c;
236+
arm_coreboot = kern/arm/coreboot/cbtable.c;
228237

229238
i386_multiboot = kern/i386/multiboot_mmap.c;
230239

@@ -752,6 +761,7 @@ module = {
752761
enable = arm_efi;
753762
enable = arm64_efi;
754763
enable = arm_uboot;
764+
enable = arm_coreboot;
755765
};
756766

757767
module = {
@@ -819,7 +829,7 @@ module = {
819829
common = commands/gptsync.c;
820830
};
821831

822-
module = {
832+
/*module = {
823833
name = halt;
824834
nopc = commands/halt.c;
825835
i386_pc = commands/i386/pc/halt.c;
@@ -854,7 +864,7 @@ module = {
854864
xen = lib/xen/reboot.c;
855865
uboot = lib/uboot/reboot.c;
856866
common = commands/reboot.c;
857-
};
867+
};*/
858868

859869
module = {
860870
name = hashsum;
@@ -1546,6 +1556,7 @@ module = {
15461556
cmos = lib/cmos_datetime.c;
15471557
efi = lib/efi/datetime.c;
15481558
uboot = lib/uboot/datetime.c;
1559+
arm_coreboot = lib/uboot/datetime.c;
15491560
sparc64_ieee1275 = lib/ieee1275/datetime.c;
15501561
powerpc_ieee1275 = lib/ieee1275/datetime.c;
15511562
sparc64_ieee1275 = lib/ieee1275/cmos.c;
@@ -1655,7 +1666,7 @@ module = {
16551666
arm64 = loader/arm64/xen_boot.c;
16561667
enable = arm64;
16571668
};
1658-
1669+
/*
16591670
module = {
16601671
name = linux;
16611672
x86 = loader/i386/linux.c;
@@ -1671,7 +1682,7 @@ module = {
16711682
common = lib/cmdline.c;
16721683
enable = noemu;
16731684
};
1674-
1685+
*/
16751686
module = {
16761687
name = fdt;
16771688
arm64 = loader/arm64/fdt.c;

grub-core/commands/i386/coreboot/cb_timestamps.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <grub/misc.h>
2121
#include <grub/command.h>
2222
#include <grub/i18n.h>
23-
#include <grub/i386/coreboot/lbio.h>
23+
#include <grub/coreboot/lbio.h>
2424
#include <grub/i386/tsc.h>
2525

2626
GRUB_MOD_LICENSE ("GPLv3+");

grub-core/commands/i386/coreboot/cbls.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <grub/misc.h>
2121
#include <grub/command.h>
2222
#include <grub/i18n.h>
23-
#include <grub/i386/coreboot/lbio.h>
23+
#include <grub/coreboot/lbio.h>
2424
#include <grub/i386/tsc.h>
2525

2626
GRUB_MOD_LICENSE ("GPLv3+");

grub-core/kern/arm/coreboot/cbtable.c

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* GRUB -- GRand Unified Bootloader
3+
* Copyright (C) 2007,2008,2013 Free Software Foundation, Inc.
4+
*
5+
* GRUB is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* GRUB is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include <grub/coreboot/lbio.h>
20+
#include <grub/types.h>
21+
#include <grub/err.h>
22+
#include <grub/misc.h>
23+
#include <grub/dl.h>
24+
#include <grub/arm/startup.h>
25+
26+
GRUB_MOD_LICENSE ("GPLv3+");
27+
28+
#pragma GCC diagnostic ignored "-Wcast-align"
29+
30+
/* Helper for grub_linuxbios_table_iterate. */
31+
static int
32+
check_signature (grub_linuxbios_table_header_t tbl_header)
33+
{
34+
if (! grub_memcmp (tbl_header->signature, "LBIO", 4))
35+
return 1;
36+
37+
return 0;
38+
}
39+
40+
grub_err_t
41+
grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t,
42+
void *),
43+
void *hook_data)
44+
{
45+
grub_linuxbios_table_header_t table_header
46+
= (grub_linuxbios_table_header_t) grub_arm_saved_registers.r[0];
47+
grub_linuxbios_table_item_t table_item;
48+
49+
if (!check_signature (table_header))
50+
return 0;
51+
52+
signature_found:
53+
table_item =
54+
(grub_linuxbios_table_item_t) ((char *) table_header +
55+
table_header->header_size);
56+
for (; table_item < (grub_linuxbios_table_item_t) ((char *) table_header
57+
+ table_header->header_size
58+
+ table_header->table_size);
59+
table_item = (grub_linuxbios_table_item_t) ((char *) table_item + table_item->size))
60+
{
61+
if (table_item->tag == GRUB_LINUXBIOS_MEMBER_LINK
62+
&& check_signature ((grub_linuxbios_table_header_t) (grub_addr_t)
63+
*(grub_uint64_t *) (table_item + 1)))
64+
{
65+
table_header = (grub_linuxbios_table_header_t) (grub_addr_t)
66+
*(grub_uint64_t *) (table_item + 1);
67+
goto signature_found;
68+
}
69+
if (hook (table_item, hook_data))
70+
return 1;
71+
}
72+
73+
return 0;
74+
}
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* GRUB -- GRand Unified Bootloader
3+
* Copyright (C) 2016 Free Software Foundation, Inc.
4+
*
5+
* GRUB is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* GRUB is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include <grub/symbol.h>
20+
21+
.file "coreboot.S"
22+
.text
23+
.syntax unified
24+
#if !defined (__thumb2__)
25+
.arch armv7a
26+
.arm
27+
#else
28+
.arch armv7
29+
.thumb
30+
#endif
31+
32+
FUNCTION(grub_armv7_get_timer_value)
33+
isb
34+
mrrc p15, 1, r0, r1, c14
35+
bx lr
36+
37+
FUNCTION(grub_armv7_get_timer_frequency)
38+
mrc p15, 0, r0, c14, c0, 0
39+
bx lr
40+

0 commit comments

Comments
 (0)