summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig28
-rw-r--r--common/console_common.c41
-rw-r--r--common/efi-devicepath.c222
-rw-r--r--common/efi/efi-image.c2
-rw-r--r--common/efi/efi.c9
5 files changed, 48 insertions, 254 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 0334606..5abe488 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -245,16 +245,6 @@ config BAREBOX_MAX_BARE_INIT_SIZE
this will allow your bare_init to fit in SRAM as example
ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE
-config BAREBOX_MAX_PBLX_SIZE
- depends on PBL_MULTI_IMAGES
- depends on IMAGE_COMPRESSION
- prompt "Maximum PBLX size"
- hex
- default 0xffffffff
- help
- Define the maximum size of the PBLX image.
- The pblx is a self extracting barebox binary.
-
config HAVE_CONFIGURABLE_MEMORY_LAYOUT
bool
@@ -1016,11 +1006,21 @@ config DEBUG_INFO
config DEBUG_LL
bool
depends on HAS_DEBUG_LL
- prompt "low level debug messages"
+ prompt "Low level debug messages (read help)"
help
- Enable this to get low level debug messages during barebox initialization.
- This requires SoC specific support. Most SoCs require the debug UART to be
- initialized by a debugger or first stage bootloader.
+ Enable this to get low level debug messages during barebox
+ initialization. This is helpful if you are debugging code that
+ executes before the console is initialized.
+
+ This requires SoC specific support. Most SoCs require the
+ debug UART to be initialized by a debugger or first stage
+ bootloader.
+
+ Note that selecting this option will limit barebox to a single
+ UART definition, as specified below under "low-level debugging
+ port". Attempting to boot the resulting image on a different
+ platform *will not work*, so this option should not be enabled
+ for builds that are intended to be portable.
choice
prompt "Kernel low-level debugging port"
diff --git a/common/console_common.c b/common/console_common.c
index 0131a11..a4d2636 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -79,6 +79,18 @@ void log_clean(unsigned int limit)
}
}
+static void print_colored_log_level(const int level)
+{
+ if (!console_allow_color())
+ return;
+ if (level >= ARRAY_SIZE(colored_log_level))
+ return;
+ if (!colored_log_level[level])
+ return;
+
+ puts(colored_log_level[level]);
+}
+
static void pr_puts(int level, const char *str)
{
struct log_entry *log;
@@ -108,21 +120,10 @@ nolog:
if (level > barebox_loglevel)
return;
+ print_colored_log_level(level);
puts(str);
}
-static void print_colored_log_level(const int level)
-{
- if (!console_allow_color())
- return;
- if (level >= ARRAY_SIZE(colored_log_level))
- return;
- if (!colored_log_level[level])
- return;
-
- pr_puts(level, colored_log_level[level]);
-}
-
int pr_print(int level, const char *fmt, ...)
{
va_list args;
@@ -132,8 +133,6 @@ int pr_print(int level, const char *fmt, ...)
if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel)
return 0;
- print_colored_log_level(level);
-
va_start(args, fmt);
i = vsprintf(printbuffer, fmt, args);
va_end(args);
@@ -152,8 +151,6 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...)
if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel)
return 0;
- print_colored_log_level(level);
-
if (dev->driver && dev->driver->name)
ret += sprintf(printbuffer, "%s ", dev->driver->name);
@@ -193,7 +190,7 @@ static int console_common_init(void)
}
device_initcall(console_common_init);
-void log_print(unsigned flags)
+void log_print(unsigned flags, unsigned levels)
{
struct log_entry *log;
unsigned long last = 0;
@@ -202,6 +199,16 @@ void log_print(unsigned flags)
uint64_t diff = log->timestamp - time_beginning;
unsigned long difful;
+ if (levels && !(levels & (1 << log->level)))
+ continue;
+
+ if (!(flags & (BAREBOX_LOG_PRINT_RAW | BAREBOX_LOG_PRINT_TIME
+ | BAREBOX_LOG_DIFF_TIME)))
+ print_colored_log_level(log->level);
+
+ if (flags & BAREBOX_LOG_PRINT_RAW)
+ printf("<%i>", log->level);
+
do_div(diff, 1000);
difful = diff;
diff --git a/common/efi-devicepath.c b/common/efi-devicepath.c
index 54c2f4e..2472228 100644
--- a/common/efi-devicepath.c
+++ b/common/efi-devicepath.c
@@ -453,34 +453,6 @@ struct efi_device_path end_instance_device_path = {
.length = END_DEVICE_PATH_LENGTH,
};
-unsigned long
-device_path_size(struct efi_device_path *dev_path)
-{
- struct efi_device_path *Start;
-
- Start = dev_path;
- while (!is_device_path_end(dev_path))
- dev_path = next_device_path_node(dev_path);
-
- return ((unsigned long) dev_path - (unsigned long) Start) +
- sizeof (struct efi_device_path);
-}
-
-struct efi_device_path *
-duplicate_device_path(struct efi_device_path *dev_path)
-{
- struct efi_device_path *new_dev_path;
- unsigned long Size;
-
- Size = device_path_size(dev_path);
-
- new_dev_path = malloc(Size);
- if (new_dev_path)
- memcpy(new_dev_path, dev_path, Size);
-
- return new_dev_path;
-}
-
struct efi_device_path *
device_path_from_handle(efi_handle_t Handle)
{
@@ -495,134 +467,7 @@ device_path_from_handle(efi_handle_t Handle)
return device_path;
}
-struct efi_device_path *
-device_path_instance(struct efi_device_path **device_path, unsigned long *Size)
-{
- struct efi_device_path *Start, *Next, *dev_path;
- unsigned long Count;
-
- dev_path = *device_path;
- Start = dev_path;
-
- if (!dev_path)
- return NULL;
-
- for (Count = 0;; Count++) {
- Next = next_device_path_node(dev_path);
-
- if (is_device_path_end_type(dev_path))
- break;
-
- dev_path = Next;
- }
-
- if (dev_path->sub_type == END_ENTIRE_DEVICE_PATH_SUBTYPE)
- Next = NULL;
-
- *device_path = Next;
-
- *Size = ((u8 *) dev_path) - ((u8 *) Start);
-
- return Start;
-}
-
-unsigned long
-device_path_instance_count(struct efi_device_path *device_path)
-{
- unsigned long Count, Size;
-
- Count = 0;
- while (device_path_instance(&device_path, &Size)) {
- Count += 1;
- }
-
- return Count;
-}
-
-struct efi_device_path *
-append_device_path(struct efi_device_path *Src1, struct efi_device_path *Src2)
-/*
- * Src1 may have multiple "instances" and each instance is appended
- * Src2 is appended to each instance is Src1. (E.g., it's possible
- * to append a new instance to the complete device path by passing
- * it in Src2)
- */
-{
- unsigned long src1_size, src1_inst, src2_size, Size;
- struct efi_device_path *Dst, *Inst;
- u8 *dst_pos;
-
- if (!Src1)
- return duplicate_device_path(Src2);
-
- if (!Src2) {
- return duplicate_device_path(Src1);
- }
-
- src1_size = device_path_size(Src1);
- src1_inst = device_path_instance_count(Src1);
- src2_size = device_path_size(Src2);
- Size = src1_size * src1_inst + src2_size;
-
- Dst = malloc(Size);
- if (Dst) {
- dst_pos = (u8 *) Dst;
-
- /* Copy all device path instances */
-
- while ((Inst = device_path_instance(&Src1, &Size))) {
-
- memcpy(dst_pos, Inst, Size);
- dst_pos += Size;
-
- memcpy(dst_pos, Src2, src2_size);
- dst_pos += src2_size;
-
- memcpy(dst_pos, &end_instance_device_path,
- sizeof (struct efi_device_path));
- dst_pos += sizeof (struct efi_device_path);
- }
-
- /* Change last end marker */
- dst_pos -= sizeof (struct efi_device_path);
- memcpy(dst_pos, &end_device_path,
- sizeof (struct efi_device_path));
- }
-
- return Dst;
-}
-
-struct efi_device_path *
-append_device_path_node(struct efi_device_path *Src1,
- struct efi_device_path *Src2)
-/*
- * Src1 may have multiple "instances" and each instance is appended
- * Src2 is a signal device path node (without a terminator) that is
- * appended to each instance is Src1.
- */
-{
- struct efi_device_path *Temp, *Eop;
- unsigned long length;
-
- /* Build a Src2 that has a terminator on it */
-
- length = Src2->length;
- Temp = malloc(length + sizeof (struct efi_device_path));
- if (!Temp)
- return NULL;
-
- memcpy(Temp, Src2, length);
- Eop = next_device_path_node(Temp);
- set_device_path_end_node(Eop);
-
- /* Append device paths */
-
- Src1 = append_device_path(Src1, Temp);
- free(Temp);
- return Src1;
-}
-
-struct efi_device_path *
+static struct efi_device_path *
unpack_device_path(struct efi_device_path *dev_path)
{
struct efi_device_path *Src, *Dest, *new_path;
@@ -665,71 +510,6 @@ unpack_device_path(struct efi_device_path *dev_path)
return new_path;
}
-struct efi_device_path *
-append_device_path_instance(struct efi_device_path *Src,
- struct efi_device_path *Instance)
-{
- u8 *Ptr;
- struct efi_device_path *dev_path;
- unsigned long src_size;
- unsigned long instance_size;
-
- if (Src == NULL)
- return duplicate_device_path(Instance);
-
- src_size = device_path_size(Src);
- instance_size = device_path_size(Instance);
- Ptr = malloc(src_size + instance_size);
- dev_path = (struct efi_device_path *) Ptr;
-
- memcpy(Ptr, Src, src_size);
-
- while (!is_device_path_end(dev_path))
- dev_path = next_device_path_node(dev_path);
-
- /*
- * Convert the End to an End Instance, since we are
- * appending another instacne after this one its a good
- * idea.
- */
- dev_path->sub_type = END_INSTANCE_DEVICE_PATH_SUBTYPE;
-
- dev_path = next_device_path_node(dev_path);
- memcpy(dev_path, Instance, instance_size);
-
- return (struct efi_device_path *) Ptr;
-}
-
-efi_status_t
-lib_device_path_to_interface(efi_guid_t * Protocol,
- struct efi_device_path *file_path,
- void **Interface)
-{
- efi_status_t Status;
- efi_handle_t Device;
-
- Status = BS->locate_device_path(Protocol, &file_path, &Device);
-
- if (!EFI_ERROR(Status)) {
-
- /* If we didn't get a direct match return not found */
- Status = EFI_NOT_FOUND;
-
- if (is_device_path_end(file_path)) {
-
- /* It was a direct match, lookup the protocol interface */
-
- Status =
- BS->handle_protocol(Device, Protocol, Interface);
- }
- }
-
- if (EFI_ERROR(Status))
- *Interface = NULL;
-
- return Status;
-}
-
static void
dev_path_pci(struct string *str, void *dev_path)
{
diff --git a/common/efi/efi-image.c b/common/efi/efi-image.c
index 885348d..939663a 100644
--- a/common/efi/efi-image.c
+++ b/common/efi/efi-image.c
@@ -88,7 +88,7 @@ struct linux_kernel_header {
uint32_t handover_offset; /** */
} __attribute__ ((packed));
-int efi_load_image(const char *file, efi_loaded_image_t **loaded_image,
+static int efi_load_image(const char *file, efi_loaded_image_t **loaded_image,
efi_handle_t *h)
{
void *exe;
diff --git a/common/efi/efi.c b/common/efi/efi.c
index 1f451a1..a7b25cb 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -367,8 +367,15 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table)
static int efi_core_init(void)
{
- struct device_d *dev = device_alloc("efi-cs", DEVICE_ID_SINGLE);
+ struct device_d *dev;
+ int ret;
+
+ dev = device_alloc("efi-cs", DEVICE_ID_SINGLE);
+ ret = platform_device_register(dev);
+ if (ret)
+ return ret;
+ dev = device_alloc("efi-wdt", DEVICE_ID_SINGLE);
return platform_device_register(dev);
}
core_initcall(efi_core_init);