Files
OpenCellular/src/lib/boot_device.c
Aaron Durbin dcbccd6a1e lib/boot_device: add RW boot device construct
The current boot device usage assumes read-only semantics to
the boot device. Any time someone wants to write to the
boot device a device-specific API is invoked such as SPI flash.
Instead, provide a mechanism to retrieve an object that can
be used to perform writes to the boot device. On systems where
the implementations are symmetric these devices can be treated
one-in-the-same. However, for x86 systems with memory mapped SPI
the read-only boot device provides different operations.

BUG=chrome-os-partner:55932

Change-Id: I0af324824f9e1a8e897c2453c36e865b59c4e004
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/16194
Tested-by: build bot (Jenkins)
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2016-08-19 03:07:05 +02:00

50 lines
1.3 KiB
C

/*
* This file is part of the coreboot project.
*
* Copyright 2015 Google Inc.
*
* This program 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; version 2 of the License.
*
* This program 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.
*/
#include <boot_device.h>
void __attribute__((weak)) boot_device_init(void)
{
/* Provide weak do-nothing init. */
}
static int boot_device_subregion(const struct region *sub,
struct region_device *subrd,
const struct region_device *parent)
{
if (parent == NULL)
return -1;
return rdev_chain(subrd, parent, region_offset(sub), region_sz(sub));
}
int boot_device_ro_subregion(const struct region *sub,
struct region_device *subrd)
{
/* Ensure boot device has been initialized at least once. */
boot_device_init();
return boot_device_subregion(sub, subrd, boot_device_ro());
}
int boot_device_rw_subregion(const struct region *sub,
struct region_device *subrd)
{
/* Ensure boot device has been initialized at least once. */
boot_device_init();
return boot_device_subregion(sub, subrd, boot_device_rw());
}