mirror of
http://cgit.git.savannah.gnu.org/git/grub.git
synced 2026-04-28 06:33:17 +00:00
Compare commits
92 Commits
7debdce1e9
...
arm_corebo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bf4907004 | ||
|
|
8af937d133 | ||
|
|
fc4b6e8b19 | ||
|
|
e824ec487b | ||
|
|
456f220e6a | ||
|
|
187f78ec11 | ||
|
|
0558f4cd9b | ||
|
|
80c274084d | ||
|
|
2fee7bb8de | ||
|
|
642ff2676f | ||
|
|
46f08fb93b | ||
|
|
b0300c6048 | ||
|
|
3e6d59d7cb | ||
|
|
9f8f747605 | ||
|
|
102016960d | ||
|
|
07cd46627b | ||
|
|
9e161d1302 | ||
|
|
06c92907c1 | ||
|
|
74cef4ab78 | ||
|
|
f4116c3a42 | ||
|
|
2d56c1b117 | ||
|
|
1f72ca020d | ||
|
|
3d300d7247 | ||
|
|
03104c2d98 | ||
|
|
40562ddf1e | ||
|
|
1ea06af1ae | ||
|
|
df21b9363d | ||
|
|
8efde40d0c | ||
|
|
d624e04af1 | ||
|
|
bbd85a0292 | ||
|
|
4f06545767 | ||
|
|
66d0e16425 | ||
|
|
a98c706755 | ||
|
|
95f663ec1d | ||
|
|
2b2a338ad6 | ||
|
|
6c9512b610 | ||
|
|
f447b3d2bb | ||
|
|
295fe6c548 | ||
|
|
9cd85f276f | ||
|
|
502a7c48e9 | ||
|
|
418b32f8e9 | ||
|
|
98490fc328 | ||
|
|
3625fdc0b9 | ||
|
|
1ec2b7758b | ||
|
|
f51e8d0dda | ||
|
|
ee52ea80d6 | ||
|
|
c55f74a5c5 | ||
|
|
3b1bb7f3eb | ||
|
|
0b71582111 | ||
|
|
dc491ff04a | ||
|
|
192243b13e | ||
|
|
0f3ae7324a | ||
|
|
ab8770a314 | ||
|
|
f2df41cffa | ||
|
|
b0227ce4b9 | ||
|
|
f900bea454 | ||
|
|
dc51ac70ee | ||
|
|
869a0bc476 | ||
|
|
f9ee0c3e5d | ||
|
|
8af26e386c | ||
|
|
78e9b82d2c | ||
|
|
86139504b7 | ||
|
|
35c1d629f9 | ||
|
|
bacb8f911f | ||
|
|
fbda565356 | ||
|
|
598185f806 | ||
|
|
ca2fd6c93f | ||
|
|
a29fb4722c | ||
|
|
7562f4ab53 | ||
|
|
c7d0aa5450 | ||
|
|
ceb68c6648 | ||
|
|
99291427d2 | ||
|
|
6ffee98e1b | ||
|
|
a6649f5b8e | ||
|
|
c3c14cffef | ||
|
|
84939af253 | ||
|
|
ba6d40e8bb | ||
|
|
2c3a054f4f | ||
|
|
b8eda96422 | ||
|
|
ca3962ca7b | ||
|
|
a4f7d77f7d | ||
|
|
5099975ace | ||
|
|
2f98d7648e | ||
|
|
018e382144 | ||
|
|
f5cba79512 | ||
|
|
46569db585 | ||
|
|
575c7a6e3c | ||
|
|
fc489a889d | ||
|
|
bfb517bc3b | ||
|
|
437dba573f | ||
|
|
974ba94330 | ||
|
|
963d21b76c |
@@ -162,6 +162,8 @@ kernel = {
|
||||
arm_coreboot = bus/fdt.c;
|
||||
arm_coreboot = term/ps2.c;
|
||||
arm_coreboot = term/arm/pl050.c;
|
||||
arm_coreboot = term/arm/cros.c;
|
||||
arm_coreboot = term/arm/cros_ec.c;
|
||||
arm_coreboot = commands/keylayouts.c;
|
||||
arm_coreboot = kern/arm/coreboot/dma.c;
|
||||
|
||||
|
||||
@@ -97,12 +97,30 @@ heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const void *dtb;
|
||||
static grub_size_t dtb_size;
|
||||
|
||||
static int
|
||||
iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data __attribute__ ((unused)))
|
||||
{
|
||||
if (table_item->tag != GRUB_LINUXBIOS_MEMBER_DTB)
|
||||
return 0;
|
||||
|
||||
if (grub_fdt_check_header (table_item + 1, table_item->size) >= 0)
|
||||
{
|
||||
dtb = table_item + 1;
|
||||
dtb_size = table_item->size;
|
||||
}
|
||||
else
|
||||
grub_printf ("Invalid DTB supplied by coreboot\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
struct grub_module_header *header;
|
||||
void *dtb = 0;
|
||||
grub_size_t dtb_size = 0;
|
||||
|
||||
modend = grub_modules_get_end ();
|
||||
|
||||
@@ -128,11 +146,14 @@ grub_machine_init (void)
|
||||
grub_memmove (dtb_copy, dtb_orig_addr, dtb_size);
|
||||
break;
|
||||
}
|
||||
if (!dtb)
|
||||
grub_linuxbios_table_iterate (iterate_linuxbios_table, 0);
|
||||
if (!dtb)
|
||||
grub_fatal ("No DTB found");
|
||||
grub_fdtbus_init (dtb, dtb_size);
|
||||
|
||||
grub_machine_timer_init ();
|
||||
grub_cros_init ();
|
||||
grub_pl050_init ();
|
||||
}
|
||||
|
||||
|
||||
119
grub-core/term/arm/cros.c
Normal file
119
grub-core/term/arm/cros.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
*
|
||||
* Copyright (C) 2012 Google Inc.
|
||||
* Copyright (C) 2016 Free Software Foundation, Inc.
|
||||
*
|
||||
* This is based on depthcharge code.
|
||||
*
|
||||
* GRUB 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/ps2.h>
|
||||
#include <grub/fdtbus.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/fdtbus.h>
|
||||
#include <grub/arm/cros_ec.h>
|
||||
|
||||
struct grub_ps2_state ps2_state;
|
||||
|
||||
struct grub_cros_ec_keyscan old_scan;
|
||||
|
||||
static grub_uint8_t map_code[GRUB_CROS_EC_KEYSCAN_COLS][GRUB_CROS_EC_KEYSCAN_ROWS];
|
||||
|
||||
static grub_uint8_t e0_translate[16] =
|
||||
{
|
||||
0x1c, 0x1d, 0x35, 0x00,
|
||||
0x38, 0x00, 0x47, 0x48,
|
||||
0x49, 0x4b, 0x4d, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53,
|
||||
};
|
||||
|
||||
/* If there is a character pending, return it;
|
||||
otherwise return GRUB_TERM_NO_KEY. */
|
||||
static int
|
||||
grub_cros_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_cros_ec_keyscan scan;
|
||||
int i, j;
|
||||
if (grub_cros_ec_scan_keyboard(&scan) < 0)
|
||||
return GRUB_TERM_NO_KEY;
|
||||
for (i = 0; i < GRUB_CROS_EC_KEYSCAN_COLS; i++)
|
||||
if (scan.data[i] ^ old_scan.data[i])
|
||||
for (j = 0; j < GRUB_CROS_EC_KEYSCAN_ROWS; j++)
|
||||
if ((scan.data[i] ^ old_scan.data[i]) & (1 << j))
|
||||
{
|
||||
grub_uint8_t code = map_code[i][j];
|
||||
int ret;
|
||||
grub_uint8_t brk = 0;
|
||||
if (!(scan.data[i] & (1 << j)))
|
||||
brk = 0x80;
|
||||
grub_dprintf ("cros_keyboard", "key <%d, %d> code %x\n", i, j, code);
|
||||
if (code < 0x60)
|
||||
ret = grub_ps2_process_incoming_byte (&ps2_state, code | brk);
|
||||
else if (code >= 0x60 && code < 0x70 && e0_translate[code - 0x60])
|
||||
{
|
||||
grub_ps2_process_incoming_byte (&ps2_state, 0xe0);
|
||||
ret = grub_ps2_process_incoming_byte (&ps2_state, e0_translate[code - 0x60] | brk);
|
||||
}
|
||||
else
|
||||
ret = GRUB_TERM_NO_KEY;
|
||||
old_scan.data[i] ^= (1 << j);
|
||||
if (ret != GRUB_TERM_NO_KEY)
|
||||
return ret;
|
||||
}
|
||||
return GRUB_TERM_NO_KEY;
|
||||
}
|
||||
|
||||
static struct grub_term_input grub_cros_keyboard_term =
|
||||
{
|
||||
.name = "cros_keyboard",
|
||||
.getkey = grub_cros_keyboard_getkey
|
||||
};
|
||||
|
||||
static grub_err_t
|
||||
cros_attach(const struct grub_fdtbus_dev *dev __attribute__ ((unused)))
|
||||
{
|
||||
grub_size_t keymap_size, i;
|
||||
const grub_uint8_t *keymap = grub_fdtbus_get_prop (dev, "linux,keymap", &keymap_size);
|
||||
|
||||
if (keymap)
|
||||
{
|
||||
for (i = 0; i + 3 < keymap_size; i += 4)
|
||||
if (keymap[i+1] < GRUB_CROS_EC_KEYSCAN_COLS && keymap[i] < GRUB_CROS_EC_KEYSCAN_ROWS
|
||||
&& keymap[i+2] == 0 && keymap[i+3] < 0x80)
|
||||
map_code[keymap[i+1]][keymap[i]] = keymap[i+3];
|
||||
}
|
||||
|
||||
ps2_state.current_set = 1;
|
||||
ps2_state.at_keyboard_status = 0;
|
||||
grub_term_register_input ("cros_keyboard", &grub_cros_keyboard_term);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
struct grub_fdtbus_driver cros =
|
||||
{
|
||||
.compatible = "google,cros-ec-keyb",
|
||||
.attach = cros_attach
|
||||
};
|
||||
|
||||
void
|
||||
grub_cros_init (void)
|
||||
{
|
||||
grub_fdtbus_register (&cros);
|
||||
}
|
||||
287
grub-core/term/arm/cros_ec.c
Normal file
287
grub-core/term/arm/cros_ec.c
Normal file
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
*
|
||||
* Copyright (C) 2012 Google Inc.
|
||||
* Copyright (C) 2016 Free Software Foundation, Inc.
|
||||
*
|
||||
* This is based on depthcharge code.
|
||||
*
|
||||
* GRUB 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/arm/cros_ec.h>
|
||||
|
||||
static grub_uint64_t
|
||||
grub_get_time_us (void)
|
||||
{
|
||||
return 1000 * grub_get_time_ms ();
|
||||
}
|
||||
|
||||
static void
|
||||
grub_microsleep (grub_uint64_t len)
|
||||
{
|
||||
grub_uint64_t end_time = grub_get_time_us () + len;
|
||||
while (grub_get_time_us () < end_time)
|
||||
grub_cpu_idle ();
|
||||
}
|
||||
|
||||
volatile grub_uint32_t *spi = (volatile grub_uint32_t *) 0xff110000;
|
||||
|
||||
static int
|
||||
spi_send (const void *data, grub_size_t sz)
|
||||
{
|
||||
const grub_uint8_t *ptr = data, *end = ptr + sz;
|
||||
spi[2] = 0;
|
||||
spi[1] = sz - 1;
|
||||
spi[0] = ((1 << 18) | spi[0]) & ~(1 << 19);
|
||||
spi[2] = 1;
|
||||
while (ptr < end)
|
||||
{
|
||||
while (spi[9] & 2);
|
||||
spi[256] = *ptr++;
|
||||
}
|
||||
while (spi[9] & 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spi_read (void *data, grub_size_t sz)
|
||||
{
|
||||
grub_uint8_t *ptr = data, *end = ptr + sz;
|
||||
spi[2] = 0;
|
||||
spi[1] = sz - 1;
|
||||
spi[0] = ((1 << 19) | spi[0]) & ~(1 << 18);
|
||||
spi[2] = 1;
|
||||
while (ptr < end)
|
||||
{
|
||||
while (spi[9] & 8);
|
||||
*ptr++ = spi[512];
|
||||
}
|
||||
while (spi[9] & 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spi_start (void)
|
||||
{
|
||||
spi[3] = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
spi_stop (void)
|
||||
{
|
||||
spi[3] = 0;
|
||||
}
|
||||
|
||||
#define uint8_t grub_uint8_t
|
||||
#define uint16_t grub_uint16_t
|
||||
#define uint32_t grub_uint32_t
|
||||
#define uint64_t grub_uint64_t
|
||||
#define mdelay grub_millisleep
|
||||
#define memcpy grub_memcpy
|
||||
|
||||
static const uint64_t FramingTimeoutUs = 300 * 1000;
|
||||
|
||||
static const uint8_t EcFramingByte = 0xec;
|
||||
|
||||
#define EC_CMD_MKBP_STATE 0x60
|
||||
#define EC_CMD_VERSION0 0xdc
|
||||
|
||||
static uint64_t last_transfer;
|
||||
|
||||
static void
|
||||
stop_bus (void)
|
||||
{
|
||||
spi_stop ();
|
||||
last_transfer = grub_get_time_us ();
|
||||
}
|
||||
|
||||
static int
|
||||
wait_for_frame (void)
|
||||
{
|
||||
uint64_t start = grub_get_time_us ();
|
||||
uint8_t byte;
|
||||
do
|
||||
{
|
||||
if (spi_read (&byte, 1))
|
||||
return -1;
|
||||
if (byte != EcFramingByte &&
|
||||
grub_get_time_us () - start > FramingTimeoutUs)
|
||||
{
|
||||
grub_dprintf ("cros", "Timeout waiting for framing byte.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (byte != EcFramingByte);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate a simple 8-bit checksum of a data block
|
||||
*
|
||||
* @param data Data block to checksum
|
||||
* @param size Size of data block in bytes
|
||||
* @return checksum value (0 to 255)
|
||||
*/
|
||||
static uint8_t
|
||||
cros_ec_calc_checksum (const void *data, int size)
|
||||
{
|
||||
uint8_t csum;
|
||||
const uint8_t *bytes = data;
|
||||
int i;
|
||||
|
||||
for (i = csum = 0; i < size; i++)
|
||||
csum += bytes[i];
|
||||
return csum & 0xff;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
/* response, arglen */
|
||||
CROS_EC_SPI_IN_HDR_SIZE = 2,
|
||||
/* version, cmd, arglen */
|
||||
CROS_EC_SPI_OUT_HDR_SIZE = 3
|
||||
};
|
||||
|
||||
static grub_uint8_t busbuf[256];
|
||||
#define MSG_BYTES ((int)sizeof (busbuf))
|
||||
|
||||
static int
|
||||
ec_command (int cmd, int cmd_version,
|
||||
const void *dout, int dout_len, void *din, int din_len)
|
||||
{
|
||||
uint8_t *bytes;
|
||||
|
||||
/* Header + data + checksum. */
|
||||
uint32_t out_bytes = CROS_EC_SPI_OUT_HDR_SIZE + dout_len + 1;
|
||||
uint32_t in_bytes = CROS_EC_SPI_IN_HDR_SIZE + din_len + 1;
|
||||
|
||||
/*
|
||||
* Sanity-check I/O sizes given transaction overhead in internal
|
||||
* buffers.
|
||||
*/
|
||||
if (out_bytes > MSG_BYTES)
|
||||
{
|
||||
grub_dprintf ("cros", "Cannot send %d bytes\n", dout_len);
|
||||
return -1;
|
||||
}
|
||||
if (in_bytes > MSG_BYTES)
|
||||
{
|
||||
grub_dprintf ("cros", "Cannot receive %d bytes\n", din_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Prepare the output. */
|
||||
bytes = busbuf;
|
||||
*bytes++ = EC_CMD_VERSION0 + cmd_version;
|
||||
*bytes++ = cmd;
|
||||
*bytes++ = dout_len;
|
||||
memcpy (bytes, dout, dout_len);
|
||||
bytes += dout_len;
|
||||
|
||||
*bytes++ = cros_ec_calc_checksum (busbuf,
|
||||
CROS_EC_SPI_OUT_HDR_SIZE + dout_len);
|
||||
|
||||
while (grub_get_time_us () - last_transfer < 200)
|
||||
;
|
||||
|
||||
if (spi_start ())
|
||||
return -1;
|
||||
|
||||
/* Allow EC to ramp up clock after being awoken. */
|
||||
/* See chrome-os-partner:32223 for more details. */
|
||||
grub_microsleep (100);
|
||||
|
||||
if (spi_send (busbuf, out_bytes))
|
||||
{
|
||||
stop_bus ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait until the EC is ready. */
|
||||
if (wait_for_frame ())
|
||||
{
|
||||
stop_bus ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read the response code and the data length. */
|
||||
bytes = busbuf;
|
||||
if (spi_read (bytes, 2))
|
||||
{
|
||||
stop_bus ();
|
||||
return -1;
|
||||
}
|
||||
uint8_t result = *bytes++;
|
||||
uint8_t length = *bytes++;
|
||||
|
||||
/* Make sure there's enough room for the data. */
|
||||
if (CROS_EC_SPI_IN_HDR_SIZE + length + 1 > MSG_BYTES)
|
||||
{
|
||||
grub_dprintf ("cros", "Received length %#02x too large\n", length);
|
||||
stop_bus ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read the data and the checksum, and finish up. */
|
||||
if (spi_read (bytes, length + 1))
|
||||
{
|
||||
stop_bus ();
|
||||
return -1;
|
||||
}
|
||||
bytes += length;
|
||||
int expected = *bytes++;
|
||||
stop_bus ();
|
||||
|
||||
/* Check the integrity of the response. */
|
||||
if (result != 0)
|
||||
{
|
||||
grub_dprintf ("cros", "Received bad result code %d\n", result);
|
||||
return -result;
|
||||
}
|
||||
|
||||
int csum = cros_ec_calc_checksum (busbuf,
|
||||
CROS_EC_SPI_IN_HDR_SIZE + length);
|
||||
|
||||
if (csum != expected)
|
||||
{
|
||||
grub_dprintf ("cros", "Invalid checksum rx %#02x, calced %#02x\n",
|
||||
expected, csum);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If the caller wants the response, copy it out for them. */
|
||||
if (length < din_len)
|
||||
din_len = length;
|
||||
if (din)
|
||||
{
|
||||
memcpy (din, (uint8_t *) busbuf + CROS_EC_SPI_IN_HDR_SIZE, din_len);
|
||||
}
|
||||
|
||||
return din_len;
|
||||
}
|
||||
|
||||
int
|
||||
grub_cros_ec_scan_keyboard (struct grub_cros_ec_keyscan *scan)
|
||||
{
|
||||
if (ec_command (EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
|
||||
sizeof (*scan)) < (int) sizeof (*scan))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
0
include/grub/arm/coreboot/memory.h
Normal file
0
include/grub/arm/coreboot/memory.h
Normal file
16
include/grub/arm/cros_ec.h
Normal file
16
include/grub/arm/cros_ec.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef GRUB_ARM_CROS_EC_H
|
||||
#define GRUB_ARM_CROS_EC_H 1
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_CROS_EC_KEYSCAN_COLS 13
|
||||
#define GRUB_CROS_EC_KEYSCAN_ROWS 8
|
||||
|
||||
struct grub_cros_ec_keyscan {
|
||||
grub_uint8_t data[GRUB_CROS_EC_KEYSCAN_COLS];
|
||||
};
|
||||
|
||||
int
|
||||
grub_cros_ec_scan_keyboard(struct grub_cros_ec_keyscan *scan);
|
||||
|
||||
#endif
|
||||
@@ -71,7 +71,8 @@ enum
|
||||
GRUB_LINUXBIOS_MEMBER_LINK = 0x11,
|
||||
GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER = 0x12,
|
||||
GRUB_LINUXBIOS_MEMBER_TIMESTAMPS = 0x16,
|
||||
GRUB_LINUXBIOS_MEMBER_CBMEMC = 0x17
|
||||
GRUB_LINUXBIOS_MEMBER_CBMEMC = 0x17,
|
||||
GRUB_LINUXBIOS_MEMBER_DTB = 0x33,
|
||||
};
|
||||
|
||||
struct grub_linuxbios_table_framebuffer {
|
||||
|
||||
@@ -214,6 +214,14 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc
|
||||
string_size += sizeof (".xen");
|
||||
footer_size += XEN_NOTE_SIZE;
|
||||
}
|
||||
if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM
|
||||
&& image_target->link_addr == 0)
|
||||
{
|
||||
phnum++;
|
||||
shnum++;
|
||||
string_size += sizeof (".coreboot_flags");
|
||||
footer_size += COREBOOT_NOTE_SIZE;
|
||||
}
|
||||
header_size = ALIGN_UP (sizeof (*ehdr) + phnum * sizeof (*phdr)
|
||||
+ shnum * sizeof (*shdr) + string_size, layout->align);
|
||||
|
||||
@@ -309,6 +317,40 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc
|
||||
phdr->p_align = grub_host_to_target32 (image_target->link_align);
|
||||
}
|
||||
|
||||
if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM
|
||||
&& image_target->link_addr == 0)
|
||||
{
|
||||
char *note_start = (elf_img + program_size + header_size);
|
||||
Elf_Nhdr *note_ptr;
|
||||
char *ptr = (char *) note_start;
|
||||
|
||||
grub_util_info ("adding coreboot NOTE segment");
|
||||
|
||||
note_ptr = (Elf_Nhdr *) ptr;
|
||||
note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_COREBOOT_NOTE_NAME));
|
||||
note_ptr->n_descsz = grub_host_to_target32 (8);
|
||||
note_ptr->n_type = grub_host_to_target32 (0);
|
||||
ptr += sizeof (Elf_Nhdr);
|
||||
memcpy (ptr, GRUB_COREBOOT_NOTE_NAME, sizeof (GRUB_COREBOOT_NOTE_NAME));
|
||||
ptr += ALIGN_UP (sizeof (GRUB_COREBOOT_NOTE_NAME), 4);
|
||||
((grub_uint32_t *) ptr)[0] = grub_host_to_target32 (is_relocatable (image_target));
|
||||
((grub_uint32_t *) ptr)[1] = 0;
|
||||
((grub_uint32_t *) ptr)[2] = grub_host_to_target32 (layout->align);
|
||||
ptr += 12;
|
||||
|
||||
assert (COREBOOT_NOTE_SIZE == (ptr - note_start));
|
||||
|
||||
phdr++;
|
||||
phdr->p_type = grub_host_to_target32 (PT_NOTE);
|
||||
phdr->p_flags = grub_host_to_target32 (PF_R);
|
||||
phdr->p_align = grub_host_to_target32 (image_target->voidp_sizeof);
|
||||
phdr->p_vaddr = 0;
|
||||
phdr->p_paddr = 0;
|
||||
phdr->p_filesz = grub_host_to_target32 (COREBOOT_NOTE_SIZE);
|
||||
phdr->p_memsz = 0;
|
||||
phdr->p_offset = grub_host_to_target32 (header_size + program_size);
|
||||
}
|
||||
|
||||
if (image_target->id == IMAGE_XEN)
|
||||
{
|
||||
char *note_start = (elf_img + program_size + header_size);
|
||||
@@ -489,6 +531,26 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc
|
||||
shdr->sh_entsize = grub_host_to_target32 (0);
|
||||
shdr++;
|
||||
}
|
||||
if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM
|
||||
&& image_target->link_addr == 0)
|
||||
{
|
||||
memcpy (ptr, ".coreboot_flags", sizeof (".coreboot_flags"));
|
||||
shdr->sh_name = grub_host_to_target32 (ptr - str_start);
|
||||
ptr += sizeof (".coreboot_flags");
|
||||
shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS);
|
||||
shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size);
|
||||
shdr->sh_offset = grub_host_to_target_addr (program_size + header_size
|
||||
+ sizeof (Elf_Nhdr)
|
||||
+ ALIGN_UP (sizeof (GRUB_COREBOOT_NOTE_NAME), 4));
|
||||
shdr->sh_size = grub_host_to_target32 (COREBOOT_NOTE_SIZE
|
||||
- sizeof (Elf_Nhdr)
|
||||
- ALIGN_UP (sizeof (GRUB_COREBOOT_NOTE_NAME), 4));
|
||||
shdr->sh_link = grub_host_to_target32 (0);
|
||||
shdr->sh_info = grub_host_to_target32 (0);
|
||||
shdr->sh_addralign = grub_host_to_target32 (image_target->voidp_sizeof);
|
||||
shdr->sh_entsize = grub_host_to_target32 (0);
|
||||
shdr++;
|
||||
}
|
||||
}
|
||||
|
||||
free (*core_img);
|
||||
|
||||
@@ -533,6 +533,24 @@ static const struct grub_install_image_target_desc image_targets[] =
|
||||
.mod_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN,
|
||||
.link_align = 4
|
||||
},
|
||||
{
|
||||
.dirname = "arm-coreboot",
|
||||
.names = { "arm-coreboot", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_COREBOOT,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.total_module_size = GRUB_KERNEL_ARM_COREBOOT_TOTAL_MODULE_SIZE,
|
||||
.decompressor_compressed_size = TARGET_NO_FIELD,
|
||||
.decompressor_uncompressed_size = TARGET_NO_FIELD,
|
||||
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
|
||||
.section_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN,
|
||||
.vaddr_offset = 0,
|
||||
.elf_target = EM_ARM,
|
||||
.mod_gap = GRUB_KERNEL_ARM_COREBOOT_MOD_GAP,
|
||||
.mod_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN,
|
||||
.link_align = 4,
|
||||
},
|
||||
/* For coreboot versions that don't support self-relocating images. */
|
||||
{
|
||||
.dirname = "arm-coreboot-vexpress",
|
||||
|
||||
Reference in New Issue
Block a user