+// SPDX-License-Identifier: GPL-2.0+
/*
* Chromium OS cros_ec driver - sandbox emulation
*
* Copyright (c) 2013 The Chromium OS Authors.
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <ec_commands.h>
#include <errno.h>
#include <hash.h>
-#include <malloc.h>
+#include <log.h>
#include <os.h>
#include <u-boot/sha256.h>
#include <spi.h>
+#include <asm/malloc.h>
#include <asm/state.h>
#include <asm/sdl.h>
#include <linux/input.h>
* the EC image in with U-Boot (Vic has demonstrated a prototype for this).
*/
-DECLARE_GLOBAL_DATA_PTR;
-
#define KEYBOARD_ROWS 8
#define KEYBOARD_COLS 13
* @recovery_req: Keyboard recovery requested
*/
struct ec_state {
- uint8_t vbnv_context[EC_VBNV_BLOCK_SIZE];
+ u8 vbnv_context[EC_VBNV_BLOCK_SIZE_V2];
struct fdt_cros_ec ec_config;
uint8_t *flash_data;
int flash_data_len;
prop = fdt_getprop(blob, node, "flash-data", &len);
if (prop) {
ec->flash_data_len = len;
- ec->flash_data = os_malloc(len);
+ ec->flash_data = malloc(len);
if (!ec->flash_data)
return -ENOMEM;
memcpy(ec->flash_data, prop, len);
int upto;
int len;
- cell = ofnode_read_prop(node, "linux,keymap", &len);
+ cell = ofnode_get_property(node, "linux,keymap", &len);
ec->matrix_count = len / 4;
ec->matrix = calloc(ec->matrix_count, sizeof(*ec->matrix));
if (!ec->matrix) {
switch (req->op) {
case EC_VBNV_CONTEXT_OP_READ:
+ /* TODO(sjg@chromium.org): Support full-size context */
memcpy(resp->block, ec->vbnv_context,
- sizeof(resp->block));
- len = sizeof(*resp);
+ EC_VBNV_BLOCK_SIZE);
+ len = 16;
break;
case EC_VBNV_CONTEXT_OP_WRITE:
- memcpy(ec->vbnv_context, resp->block,
- sizeof(resp->block));
+ /* TODO(sjg@chromium.org): Support full-size context */
+ memcpy(ec->vbnv_context, req->block,
+ EC_VBNV_BLOCK_SIZE);
len = 0;
break;
default:
struct fmap_entry *entry;
int ret, size;
- entry = &ec->ec_config.region[EC_FLASH_REGION_RW];
+ entry = &ec->ec_config.region[EC_FLASH_REGION_ACTIVE];
switch (req->cmd) {
case EC_VBOOT_HASH_RECALC:
switch (req->region) {
case EC_FLASH_REGION_RO:
- case EC_FLASH_REGION_RW:
+ case EC_FLASH_REGION_ACTIVE:
case EC_FLASH_REGION_WP_RO:
entry = &ec->ec_config.region[req->region];
resp->offset = entry->offset;
return in_bytes;
}
-void cros_ec_check_keyboard(struct cros_ec_dev *dev)
+void cros_ec_check_keyboard(struct udevice *dev)
{
- struct ec_state *ec = dev_get_priv(dev->dev);
+ struct ec_state *ec = dev_get_priv(dev);
ulong start;
printf("Press keys for EC to detect on reset (ESC=recovery)...");
ec->flash_data_len != ec->ec_config.flash.length) {
printf("EC data length is %x, expected %x, discarding data\n",
ec->flash_data_len, ec->ec_config.flash.length);
- os_free(ec->flash_data);
+ free(ec->flash_data);
ec->flash_data = NULL;
}
/* Otherwise allocate the memory */
if (!ec->flash_data) {
ec->flash_data_len = ec->ec_config.flash.length;
- ec->flash_data = os_malloc(ec->flash_data_len);
+ ec->flash_data = malloc(ec->flash_data_len);
if (!ec->flash_data)
return -ENOMEM;
}