Marc Jones (marc.jones(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7910
-gerrit
commit fad89acc9d0ffd7b98b8c47bbfbdd28cfc48e8bb
Author: Julius Werner <jwerner(a)chromium.org>
Date: Tue May 20 17:56:25 2014 -0700
libpayload: video: Check for 'console' pointer before dereferencing it
Seems that the 'if (cursor_enabled)' check in
video_console_fixup_cursor() that was removed in commit 1f880bca0 really
meant to check for 'if (console)'. Looks like the whole video console
driver is built extra robust to not fail no matter how screwed up the
console is, so let's add this missing check here as well. Also fixed up
a few other missing 'if (!console)' checks while I'm at it.
However, what payloads should really be doing is check the return value
of video_(console_)init() and not call the other video functions if that
failed. This also adapts video_console_init() to correctly pass through
the return value for that purpose (something that seems to have been
overlooked in the dd9e4e58 refactoring).
BUG=chrome-os-partner:28494
TEST=None. I don't know what Dave did to trigger this in the first
place, but it's pretty straight-forward.
Original-Change-Id: I1b9f09d49dc70dacf20621b19e081c754d4814f7
Original-Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/200688
Original-Reviewed-by: David Hendricks <dhendrix(a)chromium.org>
(cherry picked from commit 3f01d1dc0974774f0b3ba5fc4e069978f266f2fc)
Signed-off-by: Marc Jones <marc.jones(a)se-eng.com>
Change-Id: I98c1d8360539b457e6df07cbcf799acaf6c4631b
---
payloads/libpayload/drivers/video/video.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/payloads/libpayload/drivers/video/video.c b/payloads/libpayload/drivers/video/video.c
index 318548b..5f76a30 100644
--- a/payloads/libpayload/drivers/video/video.c
+++ b/payloads/libpayload/drivers/video/video.c
@@ -73,6 +73,9 @@ void video_get_rows_cols(unsigned int *rows, unsigned int *cols)
static void video_console_fixup_cursor(void)
{
+ if (!console)
+ return;
+
if (cursorx < 0)
cursorx = 0;
@@ -89,7 +92,7 @@ static void video_console_fixup_cursor(void)
cursory--;
}
- if (console && console->set_cursor)
+ if (console->set_cursor)
console->set_cursor(cursorx, cursory);
}
@@ -119,6 +122,9 @@ void video_console_putc(u8 row, u8 col, unsigned int ch)
void video_console_putchar(unsigned int ch)
{
+ if (!console)
+ return;
+
/* replace black-on-black with light-gray-on-black.
* do it here, instead of in libc/console.c
*/
@@ -145,16 +151,11 @@ void video_console_putchar(unsigned int ch)
break;
case '\t':
- while(cursorx % 8 && cursorx < console->columns) {
- if (console)
- console->putc(cursory, cursorx, (ch & 0xFF00) | ' ');
-
- cursorx++;
- }
+ while(cursorx % 8 && cursorx < console->columns)
+ console->putc(cursory, cursorx++, (ch & 0xFF00) | ' ');
break;
default:
- if (console)
- console->putc(cursory, cursorx++, ch);
+ console->putc(cursory, cursorx++, ch);
break;
}
@@ -167,7 +168,7 @@ void video_console_get_cursor(unsigned int *x, unsigned int *y, unsigned int *en
*y=0;
*en=0;
- if (console->get_cursor)
+ if (console && console->get_cursor)
console->get_cursor(x, y, en);
*x = cursorx;
@@ -214,9 +215,10 @@ int video_init(void)
int video_console_init(void)
{
- video_init();
- if (console)
- console_add_output_driver(&cons);
+ int ret = video_init();
+ if (ret)
+ return ret;
+ console_add_output_driver(&cons);
return 0;
}
Marc Jones (marc.jones(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7904
-gerrit
commit b4e71fba7e35dd9395bc94e0d22c43049ae449e5
Author: Julius Werner <jwerner(a)chromium.org>
Date: Fri May 2 16:35:50 2014 -0700
libpayload: usbmsc: Implement limited LUN support
I always thought the support for multiple logical SCSI units in the USB
mass storage class was a dead feature. Turns out that it's actually used
by SD card readers that provide multiple slots (e.g. one regular sized
and one micro-SD). Implementing perfect support for that would require a
major redesign of the whole MSC stack, since the one device -> one disk
assumption is deeply embedded in our data structures.
Instead, this patch implements a poor man's LUN support that will just
cycle through all available LUNs (in multiple calls to usb_msc_poll())
until it finds a connected device. This should be reasonable enough to
allow these card readers to be usable while only requiring superficial
changes.
Also removes the unused 'protocol' attribute of usb_msc_inst_t.
BRANCH=rambi?,nyan
BUG=chrome-os-partner:28437
TEST=Alternatively plug an SD or micro-SD card (or both) into my card
reader, confirm that one of them is correctly detected at all times.
Original-Change-Id: I3df4ca88afe2dcf7928b823aa2a73c2b0f599cf2
Original-Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/198101
Original-Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
(cherry picked from commit 960534a20e4334772c29355bb0d310b3f41b31ee)
Signed-off-by: Marc Jones <marc.jones(a)se-eng.com>
Change-Id: I39909fc96e32c9a5d76651d91c2b5c16c89ace9e
---
payloads/libpayload/drivers/usb/usbmsc.c | 41 +++++++++++++++++++-------------
payloads/libpayload/include/usb/usbmsc.h | 7 +++---
2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/payloads/libpayload/drivers/usb/usbmsc.c b/payloads/libpayload/drivers/usb/usbmsc.c
index 3b5206e..62428b6 100644
--- a/payloads/libpayload/drivers/usb/usbmsc.c
+++ b/payloads/libpayload/drivers/usb/usbmsc.c
@@ -170,10 +170,10 @@ reset_transport (usbdev_t *dev)
}
/* device may stall this command, so beware! */
-static int
-get_max_luns (usbdev_t *dev)
+static void
+initialize_luns (usbdev_t *dev)
{
- unsigned char luns = 75;
+ usbmsc_inst_t *msc = MSC_INST (dev);
dev_req_t dr;
dr.bmRequestType = 0;
dr.data_dir = device_to_host;
@@ -185,23 +185,24 @@ get_max_luns (usbdev_t *dev)
dr.wValue = 0;
dr.wIndex = 0;
dr.wLength = 1;
- if (dev->controller->control (dev, IN, sizeof (dr), &dr, 1, &luns) < 0)
- luns = 0; // assume only 1 lun if req fails
- return luns;
+ if (dev->controller->control (dev, IN, sizeof (dr), &dr,
+ sizeof (msc->num_luns), &msc->num_luns) < 0)
+ msc->num_luns = 0; /* assume only 1 lun if req fails */
+ msc->num_luns++; /* Get Max LUN returns number of last LUN */
+ msc->lun = 0;
}
unsigned int tag;
-unsigned char lun = 0;
static void
wrap_cbw (cbw_t *cbw, int datalen, cbw_direction dir, const u8 *cmd,
- int cmdlen)
+ int cmdlen, u8 lun)
{
memset (cbw, 0, sizeof (cbw_t));
cbw->dCBWSignature = cbw_signature;
cbw->dCBWTag = ++tag;
- cbw->bCBWLUN = lun; // static value per device
+ cbw->bCBWLUN = lun;
cbw->dCBWDataTransferLength = datalen;
cbw->bmCBWFlags = dir;
@@ -236,7 +237,7 @@ execute_command (usbdev_t *dev, cbw_direction dir, const u8 *cb, int cblen,
if ((cb[0] == 0x1b) && (cb[4] == 1)) { //start command, always succeed
always_succeed = 1;
}
- wrap_cbw (&cbw, buflen, dir, cb, cblen);
+ wrap_cbw (&cbw, buflen, dir, cb, cblen, MSC_INST (dev)->lun);
if (dev->controller->
bulk (MSC_INST (dev)->bulk_out, sizeof (cbw), (u8 *) &cbw, 0) < 0) {
return reset_transport (dev);
@@ -623,7 +624,6 @@ usb_msc_init (usbdev_t *dev)
if (!dev->data)
fatal("Not enough memory for USB MSC device.\n");
- MSC_INST (dev)->protocol = interface->bInterfaceSubClass;
MSC_INST (dev)->bulk_in = 0;
MSC_INST (dev)->bulk_out = 0;
MSC_INST (dev)->usbdisk_created = 0;
@@ -655,7 +655,8 @@ usb_msc_init (usbdev_t *dev)
MSC_INST (dev)->bulk_in->endpoint,
MSC_INST (dev)->bulk_out->endpoint);
- usb_debug (" has %d luns\n", get_max_luns (dev) + 1);
+ initialize_luns (dev);
+ usb_debug (" has %d luns\n", MSC_INST (dev)->num_luns);
/* Test if unit is ready (nothing to do if it isn't). */
if (usb_msc_test_unit_ready (dev) != USB_MSC_READY)
@@ -668,16 +669,22 @@ usb_msc_init (usbdev_t *dev)
static void
usb_msc_poll (usbdev_t *dev)
{
- int prev_ready = MSC_INST (dev)->ready;
+ usbmsc_inst_t *msc = MSC_INST (dev);
+ int prev_ready = msc->ready;
if (usb_msc_test_unit_ready (dev) == USB_MSC_DETACHED)
return;
- if (!prev_ready && MSC_INST (dev)->ready) {
- usb_debug ("usb msc: not ready -> ready\n");
+ if (!prev_ready && msc->ready) {
+ usb_debug ("usb msc: not ready -> ready (lun %d)\n", msc->lun);
usb_msc_create_disk (dev);
- } else if (prev_ready && !MSC_INST (dev)->ready) {
- usb_debug ("usb msc: ready -> not ready\n");
+ } else if (prev_ready && !msc->ready) {
+ usb_debug ("usb msc: ready -> not ready (lun %d)\n", msc->lun);
usb_msc_remove_disk (dev);
+ } else if (!prev_ready && !msc->ready) {
+ u8 new_lun = (msc->lun + 1) % msc->num_luns;
+ usb_debug("usb msc: not ready (lun %d) -> lun %d\n", msc->lun,
+ new_lun);
+ msc->lun = new_lun;
}
}
diff --git a/payloads/libpayload/include/usb/usbmsc.h b/payloads/libpayload/include/usb/usbmsc.h
index 8930156..f4562a5 100644
--- a/payloads/libpayload/include/usb/usbmsc.h
+++ b/payloads/libpayload/include/usb/usbmsc.h
@@ -32,11 +32,12 @@
typedef struct {
unsigned int blocksize;
unsigned int numblocks;
- unsigned int protocol;
endpoint_t *bulk_in;
endpoint_t *bulk_out;
- int usbdisk_created;
- int ready;
+ u8 usbdisk_created;
+ s8 ready;
+ u8 lun;
+ u8 num_luns;
void *data; /* For use by consumers of libpayload. */
} usbmsc_inst_t;
Marc Jones (marc.jones(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7907
-gerrit
commit eab321df3eb87e8e55c5bd097e4d2d0cbdc91036
Author: Hung-Te Lin <hungte(a)chromium.org>
Date: Tue May 13 22:33:12 2014 +0800
libpayload: Provide selfboot function.
The calling convention of payload entry function is different by architecture.
For example, X86 takes no arguments and ARM needs first param to be a
cb_header_ptr*.
To help payloads load and execute other payloads easily and correctly, we should
provide the selfboot() function in libpayload, using same prototype as defined
in Coreboot environment.
BUG=none
TEST=emerge-nyan libpayload # pass
BRANCH=none
Original-Change-Id: I8f1cb2c0df788794b2f6f7f5500a3910328a4f84
Original-Signed-off-by: Hung-Te Lin <hungte(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/199503
Original-Reviewed-by: Stefan Reinauer <reinauer(a)chromium.org>
(cherry picked from commit 1e916cf021ce68886eb9668982c392eadedc7b7e)
Signed-off-by: Marc Jones <marc.jones(a)se-eng.com>
Change-Id: I7279ef27f49ef581d25a455dd8f1f2f7f1ba58cb
---
payloads/libpayload/arch/arm/Makefile.inc | 1 +
payloads/libpayload/arch/arm/selfboot.c | 35 +++++++++++++++++++++++++++++++
payloads/libpayload/arch/x86/Makefile.inc | 1 +
payloads/libpayload/arch/x86/selfboot.c | 28 +++++++++++++++++++++++++
payloads/libpayload/include/cbfs.h | 3 +--
5 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/payloads/libpayload/arch/arm/Makefile.inc b/payloads/libpayload/arch/arm/Makefile.inc
index 5c22ea8..7009884 100644
--- a/payloads/libpayload/arch/arm/Makefile.inc
+++ b/payloads/libpayload/arch/arm/Makefile.inc
@@ -38,6 +38,7 @@ libc-y += virtual.c
libc-y += memcpy.S memset.S memmove.S
libc-y += exception_asm.S exception.c
libc-y += cache.c cpu.S
+libc-y += selfboot.c
libcbfs-$(CONFIG_LP_CBFS) += dummy_media.c
# Add other classes here when you put assembly files into them!
diff --git a/payloads/libpayload/arch/arm/selfboot.c b/payloads/libpayload/arch/arm/selfboot.c
new file mode 100644
index 0000000..cbb7ef1
--- /dev/null
+++ b/payloads/libpayload/arch/arm/selfboot.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <libpayload.h>
+
+extern void *cb_header_ptr;
+
+void selfboot(void *entry)
+{
+ __asm__ __volatile__(
+ "mov r0, %[cb_header_ptr]\n"
+ "bx %[entry]\n"
+ :: [cb_header_ptr]"r"(cb_header_ptr), [entry]"r"(entry)
+ : "r0"
+ );
+}
diff --git a/payloads/libpayload/arch/x86/Makefile.inc b/payloads/libpayload/arch/x86/Makefile.inc
index 549a630..d9cc19e 100644
--- a/payloads/libpayload/arch/x86/Makefile.inc
+++ b/payloads/libpayload/arch/x86/Makefile.inc
@@ -31,6 +31,7 @@ head.o-y += head.S
libc-y += main.c sysinfo.c
libc-y += timer.c coreboot.c util.S
libc-y += exec.S virtual.c
+libc-y += selfboot.c
libc-y += string.c
libc-y += exception_asm.S exception.c
diff --git a/payloads/libpayload/arch/x86/selfboot.c b/payloads/libpayload/arch/x86/selfboot.c
new file mode 100644
index 0000000..fc89859
--- /dev/null
+++ b/payloads/libpayload/arch/x86/selfboot.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <libpayload.h>
+
+void selfboot(void *entry)
+{
+ void (*entry_func)(void) = entry;
+ entry_func();
+}
diff --git a/payloads/libpayload/include/cbfs.h b/payloads/libpayload/include/cbfs.h
index df3bb1c..c5c811c 100644
--- a/payloads/libpayload/include/cbfs.h
+++ b/payloads/libpayload/include/cbfs.h
@@ -82,8 +82,7 @@ void *cbfs_simple_buffer_unmap(struct cbfs_simple_buffer *buffer,
int run_address(void *f);
/* Defined in src/lib/selfboot.c */
-struct lb_memory;
-int selfboot(struct lb_memory *mem, struct cbfs_payload *payload);
+void selfboot(void *entry);
/* Defined in individual arch / board implementation. */
int init_default_cbfs_media(struct cbfs_media *media);
Marc Jones (marc.jones(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7922
-gerrit
commit 7d8762cbc7a5e1fdac9162688907f666af3b4bbd
Author: Marc Jones <marc.jones(a)se-eng.com>
Date: Tue Dec 23 15:22:30 2014 -0700
libpayload: Remove PC Keyboard from ARM build
The keyboard.c uses IO cycles to access the legacy PC keyboard device.
ARM can't do IO cycles, so remove the option for ARM configs.
Change-Id: Ifc6c2368563f27867f4babad5afdde0e78f4cf78
Signed-off-by: Marc Jones <marc.jones(a)se-eng.com>
---
payloads/libpayload/Config.in | 3 ++-
payloads/libpayload/configs/defconfig-arm | 8 ++------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/payloads/libpayload/Config.in b/payloads/libpayload/Config.in
index f317c18..bef0e05 100644
--- a/payloads/libpayload/Config.in
+++ b/payloads/libpayload/Config.in
@@ -237,7 +237,8 @@ config COREBOOT_VIDEO_CONSOLE
config PC_KEYBOARD
bool "Allow input from a PC keyboard"
- default y
+ default y if ARCH_X86 # uses IO
+ default n
config PC_KEYBOARD_LAYOUT_US
bool "English (US) keyboard layout"
diff --git a/payloads/libpayload/configs/defconfig-arm b/payloads/libpayload/configs/defconfig-arm
index 12ad423..fe47d0c 100644
--- a/payloads/libpayload/configs/defconfig-arm
+++ b/payloads/libpayload/configs/defconfig-arm
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# libpayload version: 0.2.0
-# Wed Nov 12 14:57:03 2014
+# Tue Dec 23 15:19:30 2014
#
#
@@ -42,9 +42,7 @@ CONFIG_LP_SERIAL_CONSOLE=y
# CONFIG_LP_SERIAL_ACS_FALLBACK is not set
CONFIG_LP_VIDEO_CONSOLE=y
# CONFIG_LP_COREBOOT_VIDEO_CONSOLE is not set
-CONFIG_LP_PC_KEYBOARD=y
-CONFIG_LP_PC_KEYBOARD_LAYOUT_US=y
-# CONFIG_LP_PC_KEYBOARD_LAYOUT_DE is not set
+# CONFIG_LP_PC_KEYBOARD is not set
#
# Drivers
@@ -70,5 +68,3 @@ CONFIG_LP_USB_GEN_HUB=y
CONFIG_LP_LITTLE_ENDIAN=y
# CONFIG_LP_IO_ADDRESS_SPACE is not set
CONFIG_LP_ARCH_SPECIFIC_OPTIONS=y
-CONFIG_LP_COREBOOT_INFO_RANGE_BASE=0x10
-CONFIG_LP_COREBOOT_INFO_RANGE_SIZE=0x4000000
Marc Jones (marc.jones(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7906
-gerrit
commit 783e932a66408f5d351817c9a7c01293ba3e65e0
Author: Hung-Te Lin <hungte(a)chromium.org>
Date: Wed May 14 12:43:57 2014 +0800
libpayload: arm: Add EABI compatible utility functions.
Some EABI conformant toolchains like GCC need additional functions like raise.
To prevent payloads adding arch-specific implementations everywhere, we should
provide the default version in libpayload.
BUG=none
TEST=emerge-nyan libpayload # pass
BRANCH=none
Original-Change-Id: Id1e3c29590aa5881aefd944a7551949ce9a47b8f
Original-Signed-off-by: Hung-Te Lin <hungte(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/199686
(cherry picked from commit 395810c4b744dbb720050f79a2c1a30e81464554)
Signed-off-by: Marc Jones <marc.jones(a)se-eng.com>
Change-Id: I2e1d8c8cb519f8e788c22d081132d23b49b8f822
---
payloads/libpayload/arch/arm/Makefile.inc | 1 +
payloads/libpayload/arch/arm/eabi_compat.c | 56 ++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/payloads/libpayload/arch/arm/Makefile.inc b/payloads/libpayload/arch/arm/Makefile.inc
index 2f8da15..5c22ea8 100644
--- a/payloads/libpayload/arch/arm/Makefile.inc
+++ b/payloads/libpayload/arch/arm/Makefile.inc
@@ -31,6 +31,7 @@ CFLAGS += -mthumb -march=armv7-a
arm_asm_flags = -Wa,-mthumb -Wa,-mimplicit-it=always -Wa,-mno-warn-deprecated
head.o-y += head.S
+libc-y += eabi_compat.c
libc-y += main.c sysinfo.c
libc-y += timer.c coreboot.c util.S
libc-y += virtual.c
diff --git a/payloads/libpayload/arch/arm/eabi_compat.c b/payloads/libpayload/arch/arm/eabi_compat.c
new file mode 100644
index 0000000..0df9509
--- /dev/null
+++ b/payloads/libpayload/arch/arm/eabi_compat.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Function(s) needed for some EABI conformant tool chains (ex GCC).
+ */
+
+#include <die.h>
+
+int raise(int signum) __attribute__((weak));
+int raise(int signum)
+{
+ die("signal %d raised.\n", signum);
+ return -1;
+}
+
+/* ARM-defined Personality Routines, currently 3 in ARM EHABI. */
+
+void __aeabi_unwind_cpp_pr0(void) __attribute__((weak));
+void __aeabi_unwind_cpp_pr0(void)
+{
+}
+
+void __aeabi_unwind_cpp_pr1(void) __attribute__((weak));
+void __aeabi_unwind_cpp_pr1(void)
+{
+}
+
+void __aeabi_unwind_cpp_pr2(void) __attribute__((weak));
+void __aeabi_unwind_cpp_pr2(void)
+{
+}
Marc Jones (marc.jones(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7890
-gerrit
commit 5d61a2e3d1479e4018efcf58e973967b106d7486
Author: Gabe Black <gabeblack(a)google.com>
Date: Wed Apr 30 21:37:14 2014 -0700
rtc: Add an RTC driver for the AS3722 PMIC.
The AS3722 PMIC, like many PMICs, has an RTC built into it. This change adds a
driver for it which implements the new RTC API.
BUG=None
TEST=Built and booted with the event log code modified to use this interface.
Verified that events had accurate timestamps.
BRANCH=nyan
Original-Change-Id: I400adccbf84221dcba8d520276bb91b389f72268
Original-Signed-off-by: Gabe Black <gabeblack(a)google.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/197796
Original-Reviewed-by: Gabe Black <gabeblack(a)chromium.org>
Original-Tested-by: Gabe Black <gabeblack(a)chromium.org>
Original-Commit-Queue: Gabe Black <gabeblack(a)chromium.org>
(cherry picked from commit 011e49beba3a99abbd122866891e3c20bf1188d2)
Signed-off-by: Marc Jones <marc.jones(a)se-eng.com>
Change-Id: Ibc1d342062c7853a30d195496c077e37a02b35b0
---
src/drivers/Kconfig | 1 +
src/drivers/Makefile.inc | 1 +
src/drivers/ams/Kconfig | 11 ++++++
src/drivers/ams/Makefile.inc | 1 +
src/drivers/ams/as3722rtc.c | 91 ++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 105 insertions(+)
diff --git a/src/drivers/Kconfig b/src/drivers/Kconfig
index 12f9a79..08de415 100644
--- a/src/drivers/Kconfig
+++ b/src/drivers/Kconfig
@@ -17,6 +17,7 @@
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
+source src/drivers/ams/Kconfig
source src/drivers/ati/Kconfig
source src/drivers/dec/Kconfig
source src/drivers/elog/Kconfig
diff --git a/src/drivers/Makefile.inc b/src/drivers/Makefile.inc
index 7ae3eb2..151e3f7 100644
--- a/src/drivers/Makefile.inc
+++ b/src/drivers/Makefile.inc
@@ -17,6 +17,7 @@
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
+subdirs-y += ams
subdirs-y += ati
subdirs-y += dec
subdirs-y += emulation
diff --git a/src/drivers/ams/Kconfig b/src/drivers/ams/Kconfig
new file mode 100644
index 0000000..44b89c5
--- /dev/null
+++ b/src/drivers/ams/Kconfig
@@ -0,0 +1,11 @@
+config DRIVERS_AS3722_RTC
+ bool "AS3722 RTC support"
+ default n
+
+config DRIVERS_AS3722_RTC_BUS
+ int "AS3722 RTC bus"
+ depends on DRIVERS_AS3722_RTC
+
+config DRIVERS_AS3722_RTC_ADDR
+ hex "AS3722 RTC chip address"
+ depends on DRIVERS_AS3722_RTC
diff --git a/src/drivers/ams/Makefile.inc b/src/drivers/ams/Makefile.inc
new file mode 100644
index 0000000..cf51831
--- /dev/null
+++ b/src/drivers/ams/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_AS3722_RTC) += as3722rtc.c
diff --git a/src/drivers/ams/as3722rtc.c b/src/drivers/ams/as3722rtc.c
new file mode 100644
index 0000000..8fe5748
--- /dev/null
+++ b/src/drivers/ams/as3722rtc.c
@@ -0,0 +1,91 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <bcd.h>
+#include <console/console.h>
+#include <device/i2c.h>
+#include <rtc.h>
+#include <stdint.h>
+
+enum AS3722_RTC_REG
+{
+ AS3722_RTC_CONTROL = 0x60,
+ AS3722_RTC_SECOND = 0x61,
+ AS3722_RTC_MINUTE = 0x62,
+ AS3722_RTC_HOUR = 0x63,
+ AS3722_RTC_DAY = 0x64,
+ AS3722_RTC_MONTH = 0x65,
+ AS3722_RTC_YEAR = 0x66
+};
+
+enum {
+ AS3722_RTC_CONTROL_ON = 0x1 << 2
+};
+
+static uint8_t as3722_read(enum AS3722_RTC_REG reg)
+{
+ uint8_t val;
+ i2c_readb(CONFIG_DRIVERS_AS3722_RTC_BUS,
+ CONFIG_DRIVERS_AS3722_RTC_ADDR, reg, &val);
+ return val;
+}
+
+static void as3722_write(enum AS3722_RTC_REG reg, uint8_t val)
+{
+ i2c_writeb(CONFIG_DRIVERS_AS3722_RTC_BUS,
+ CONFIG_DRIVERS_AS3722_RTC_ADDR, reg, val);
+}
+
+static void as3722rtc_init(void)
+{
+ static int initialized;
+ if (initialized)
+ return;
+
+ uint8_t control = as3722_read(AS3722_RTC_CONTROL);
+ as3722_write(AS3722_RTC_CONTROL, control | AS3722_RTC_CONTROL_ON);
+
+ initialized = 1;
+}
+
+int rtc_set(const struct rtc_time *time)
+{
+ as3722rtc_init();
+
+ as3722_write(AS3722_RTC_SECOND, bin2bcd(time->sec));
+ as3722_write(AS3722_RTC_MINUTE, bin2bcd(time->min));
+ as3722_write(AS3722_RTC_HOUR, bin2bcd(time->hour));
+ as3722_write(AS3722_RTC_DAY, bin2bcd(time->mday));
+ as3722_write(AS3722_RTC_MONTH, bin2bcd(time->mon + 1));
+ as3722_write(AS3722_RTC_YEAR, bin2bcd(time->year));
+ return 0;
+}
+
+int rtc_get(struct rtc_time *time)
+{
+ as3722rtc_init();
+
+ time->sec = bcd2bin(as3722_read(AS3722_RTC_SECOND) & 0x7f);
+ time->min = bcd2bin(as3722_read(AS3722_RTC_MINUTE) & 0x7f);
+ time->hour = bcd2bin(as3722_read(AS3722_RTC_HOUR) & 0x3f);
+ time->mday = bcd2bin(as3722_read(AS3722_RTC_DAY) & 0x3f);
+ time->mon = bcd2bin(as3722_read(AS3722_RTC_MONTH) & 0x1f) - 1;
+ time->year = bcd2bin(as3722_read(AS3722_RTC_YEAR) & 0x7f);
+ return 0;
+}