Compare commits

...

92 Commits

Author SHA1 Message Date
Vladimir Serbinenko
3bf4907004 indent code coming from depthcharge and add missing acknowledgements 2017-05-08 22:21:31 +02:00
Vladimir Serbinenko
8af937d133 Fix spurious diffs with master 2017-05-08 22:16:47 +02:00
Vladimir Serbinenko
fc4b6e8b19 Merge branch 'master' into arm_coreboot 2017-05-08 22:15:39 +02:00
Vladimir Serbinenko
e824ec487b Merge branch 'master' into arm_coreboot 2017-05-08 22:12:00 +02:00
Vladimir Serbinenko
456f220e6a Merge branch 'master' into arm_coreboot 2017-05-08 22:06:47 +02:00
Vladimir Serbinenko
187f78ec11 Merge branch 'master' into arm_coreboot 2017-05-08 22:01:33 +02:00
Vladimir Serbinenko
0558f4cd9b fix mismerge 2017-05-08 21:31:00 +02:00
Vladimir Serbinenko
80c274084d Merge branch 'master' into arm_coreboot 2017-05-08 21:27:08 +02:00
Vladimir Serbinenko
2fee7bb8de Merge branch 'master' into arm_coreboot 2017-05-08 21:21:28 +02:00
Vladimir Serbinenko
642ff2676f fix mismerge 2017-05-08 21:08:02 +02:00
Vladimir Serbinenko
46f08fb93b Merge branch 'master' into arm_coreboot 2017-05-08 21:06:51 +02:00
Vladimir Serbinenko
b0300c6048 Merge branch 'master' into arm_coreboot 2017-05-08 17:51:27 +02:00
Vladimir Serbinenko
3e6d59d7cb Remove spurious diff with master 2017-05-08 16:47:51 +02:00
Vladimir Serbinenko
9f8f747605 usbtrans: Fix memory coherence 2016-02-23 12:07:01 +01:00
Vladimir Serbinenko
102016960d ehci: Fix memory coherence 2016-02-23 12:06:48 +01:00
Vladimir Serbinenko
07cd46627b arm: implement grub_arch_sync_dma_caches 2016-02-23 12:06:00 +01:00
Vladimir Serbinenko
9e161d1302 Make dma_caches accept volatile 2016-02-23 11:45:29 +01:00
Vladimir Serbinenko
06c92907c1 cros fix 2016-02-23 11:26:35 +01:00
Vladimir Serbinenko
74cef4ab78 cleaner 2016-02-23 10:19:26 +01:00
Vladimir Serbinenko
f4116c3a42 Decrease frame timeout 2016-02-23 10:15:05 +01:00
Vladimir Serbinenko
2d56c1b117 cleaner 2016-02-23 09:52:08 +01:00
Vladimir Serbinenko
1f72ca020d cleaner 2016-02-23 09:50:43 +01:00
Vladimir Serbinenko
3d300d7247 cleaner 2016-02-23 09:43:57 +01:00
Vladimir Serbinenko
03104c2d98 always use older cros protocol. We don't realy need new one 2016-02-23 09:42:09 +01:00
Vladimir Serbinenko
40562ddf1e cros e0 fix 2016-02-22 21:12:50 +01:00
Vladimir Serbinenko
1ea06af1ae EHCI FDT missing file 2016-02-22 20:40:16 +01:00
Vladimir Serbinenko
df21b9363d cleaner 2016-02-22 19:44:39 +01:00
Vladimir Serbinenko
8efde40d0c cleaner 2016-02-22 19:44:09 +01:00
Vladimir Serbinenko
d624e04af1 cleaner 2016-02-22 19:39:30 +01:00
Vladimir Serbinenko
bbd85a0292 cleaner 2016-02-22 19:38:26 +01:00
Vladimir Serbinenko
4f06545767 cleaner 2016-02-22 19:37:37 +01:00
Vladimir Serbinenko
66d0e16425 cleaner 2016-02-22 19:35:46 +01:00
Vladimir Serbinenko
a98c706755 cleaner 2016-02-22 19:35:16 +01:00
Vladimir Serbinenko
95f663ec1d cleaner 2016-02-22 19:34:30 +01:00
Vladimir Serbinenko
2b2a338ad6 cleaner 2016-02-22 19:33:34 +01:00
Vladimir Serbinenko
6c9512b610 cleaner 2016-02-22 19:33:13 +01:00
Vladimir Serbinenko
f447b3d2bb Dirty cros keyboard import 2016-02-22 19:29:47 +01:00
Vladimir Serbinenko
295fe6c548 Dirty cros keyboard 2016-02-22 19:29:08 +01:00
Vladimir Serbinenko
9cd85f276f frequency 2016-02-22 03:34:35 +01:00
Vladimir Serbinenko
502a7c48e9 ARM caches 2016-02-22 03:34:16 +01:00
Vladimir Serbinenko
418b32f8e9 EHCI reset fix 2016-02-22 03:33:59 +01:00
Vladimir Serbinenko
98490fc328 DMA split 2016-02-22 03:33:18 +01:00
Vladimir Serbinenko
3625fdc0b9 Improve EHCI logging 2016-02-22 03:32:50 +01:00
Vladimir Serbinenko
1ec2b7758b ehci split fixup 2016-02-22 03:28:10 +01:00
Vladimir Serbinenko
f51e8d0dda coreboot 2016-02-22 03:27:39 +01:00
Vladimir Serbinenko
ee52ea80d6 Remove useless include 2016-02-22 03:25:50 +01:00
Vladimir Serbinenko
c55f74a5c5 ehci split 2016-02-22 01:08:27 +01:00
Vladimir Serbinenko
3b1bb7f3eb DTB overrides 2016-02-22 00:05:40 +01:00
Vladimir Serbinenko
0b71582111 coreboot 2016-02-21 20:28:10 +01:00
Vladimir Serbinenko
dc491ff04a fdtbus 2016-02-21 20:27:50 +01:00
Vladimir Serbinenko
192243b13e Out-of-place FDT handling 2016-02-21 20:27:28 +01:00
Vladimir Serbinenko
0f3ae7324a fdt 2016-02-21 19:48:57 +01:00
Vladimir Serbinenko
ab8770a314 pre-located image for veyron 2016-02-21 19:28:56 +01:00
Vladimir Serbinenko
f2df41cffa coreboot 2016-02-21 19:28:40 +01:00
Vladimir Serbinenko
b0227ce4b9 fdt: relax align requirement 2016-02-21 19:28:23 +01:00
Vladimir Serbinenko
f900bea454 coreboot 2016-02-21 18:59:14 +01:00
Vladimir Serbinenko
dc51ac70ee switch to layout 2016-02-21 18:47:29 +01:00
Vladimir Serbinenko
869a0bc476 coreboot 2016-02-21 18:44:55 +01:00
Vladimir Serbinenko
f9ee0c3e5d Simplify reloc 2016-02-21 18:44:18 +01:00
Vladimir Serbinenko
8af26e386c coreboot reloc 2016-02-21 18:42:35 +01:00
Vladimir Serbinenko
78e9b82d2c coreboot memory before _start 2016-02-21 18:41:39 +01:00
Vladimir Serbinenko
86139504b7 pl050 2016-02-21 01:53:44 +01:00
Vladimir Serbinenko
35c1d629f9 fdtbus 2016-02-21 01:53:07 +01:00
Vladimir Serbinenko
bacb8f911f coreboot 2016-02-21 00:05:38 +01:00
Vladimir Serbinenko
fbda565356 fdt 2016-02-21 00:05:21 +01:00
Vladimir Serbinenko
598185f806 fdtbus 2016-02-21 00:04:18 +01:00
Vladimir Serbinenko
ca2fd6c93f ps2 split 2016-02-20 18:45:42 +01:00
Vladimir Serbinenko
a29fb4722c coreboot 2016-02-20 16:26:23 +01:00
Vladimir Serbinenko
7562f4ab53 bus fdt improvements 2016-02-20 16:25:39 +01:00
Vladimir Serbinenko
c7d0aa5450 fdtbus 2016-02-20 14:30:43 +01:00
Vladimir Serbinenko
ceb68c6648 missing files 2016-02-20 14:29:01 +01:00
Vladimir Serbinenko
99291427d2 fdtlib 2016-02-20 14:28:37 +01:00
Vladimir Serbinenko
6ffee98e1b Useless fdt.lst 2016-02-20 14:22:34 +01:00
Vladimir Serbinenko
a6649f5b8e FDT lib improvements 2016-02-20 12:30:06 +01:00
Vladimir Serbinenko
c3c14cffef refresh before abort 2016-02-20 09:12:15 +01:00
Vladimir Serbinenko
84939af253 generic timer safeguard 2016-02-20 09:12:02 +01:00
Vladimir Serbinenko
ba6d40e8bb WIP2 2016-02-19 16:47:36 +01:00
Vladimir Serbinenko
2c3a054f4f WIP 2016-02-19 12:41:50 +01:00
Vladimir Serbinenko
b8eda96422 rename 2016-02-19 12:17:56 +01:00
Vladimir Serbinenko
ca3962ca7b fix relocate 2016-02-19 12:17:20 +01:00
Vladimir Serbinenko
a4f7d77f7d fs 2016-02-19 04:48:50 +01:00
Vladimir Serbinenko
5099975ace fd 2016-02-19 04:48:17 +01:00
Vladimir Serbinenko
2f98d7648e Move cbfb 2016-02-19 04:47:02 +01:00
Vladimir Serbinenko
018e382144 decouple 2016-02-19 04:31:59 +01:00
Vladimir Serbinenko
f5cba79512 Declare arm-coreboot 2016-02-19 03:24:49 +01:00
Vladimir Serbinenko
46569db585 arm-uboot: Make self-relocatable to allow loading at any address 2016-02-19 03:22:10 +01:00
Vladimir Serbinenko
575c7a6e3c Allow _start == 0 with relocatable images 2016-02-19 02:03:28 +01:00
Vladimir Serbinenko
fc489a889d Provide __bss_start and _end symbols in grub-mkimage.
For this ensure that all bss sections are merged.
2016-02-19 02:02:50 +01:00
Vladimir Serbinenko
bfb517bc3b encapsulate 2016-02-19 01:58:11 +01:00
Vladimir Serbinenko
437dba573f Remove useless ifdef 2016-02-19 01:28:16 +01:00
Vladimir Serbinenko
974ba94330 mkimagexx: Split PE and generic part. 2016-02-19 01:14:12 +01:00
Vladimir Serbinenko
963d21b76c file split 2016-02-19 01:14:12 +01:00
9 changed files with 529 additions and 3 deletions

View File

@@ -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;

View File

@@ -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
View 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);
}

View 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;
}

View File

View 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

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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",