summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordanh-arm <dan.handley@arm.com>2014-05-06 17:54:03 +0100
committerdanh-arm <dan.handley@arm.com>2014-05-06 17:54:03 +0100
commit408c37682a0233c8c4fa88700b603f0b09d6361f (patch)
tree18133148dea88d9a2313113111b24b56e8130505 /lib
parentb495bdef190acf166c713e138b61c5bb25402fc0 (diff)
parent97043ac98e13a726dbf8b3b41654dca759e3da2c (diff)
Merge pull request #48 from danh-arm/dh/major-refactoring
dh/major refactoring
Diffstat (limited to 'lib')
-rw-r--r--lib/aarch64/cache_helpers.S (renamed from lib/arch/aarch64/cache_helpers.S)2
-rw-r--r--lib/aarch64/cpu_helpers.S56
-rw-r--r--lib/aarch64/misc_helpers.S (renamed from lib/arch/aarch64/misc_helpers.S)3
-rw-r--r--lib/aarch64/sysreg_helpers.S (renamed from lib/arch/aarch64/sysreg_helpers.S)2
-rw-r--r--lib/aarch64/tlb_helpers.S (renamed from lib/arch/aarch64/tlb_helpers.S)1
-rw-r--r--lib/aarch64/xlat_helpers.c (renamed from lib/arch/aarch64/xlat_helpers.c)3
-rw-r--r--lib/aarch64/xlat_tables.c (renamed from lib/arch/aarch64/xlat_tables.c)14
-rw-r--r--lib/io_storage.c57
-rw-r--r--lib/locks/bakery/bakery_lock.c (renamed from lib/sync/locks/bakery/bakery_lock.c)15
-rw-r--r--lib/locks/exclusive/spinlock.S (renamed from lib/sync/locks/exclusive/spinlock.S)0
-rw-r--r--lib/semihosting/semihosting.c21
11 files changed, 112 insertions, 62 deletions
diff --git a/lib/arch/aarch64/cache_helpers.S b/lib/aarch64/cache_helpers.S
index 2696d901..2649ad0e 100644
--- a/lib/arch/aarch64/cache_helpers.S
+++ b/lib/aarch64/cache_helpers.S
@@ -28,7 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch_helpers.h>
+#include <arch.h>
#include <asm_macros.S>
.globl dcisw
diff --git a/lib/aarch64/cpu_helpers.S b/lib/aarch64/cpu_helpers.S
new file mode 100644
index 00000000..573d0b8b
--- /dev/null
+++ b/lib/aarch64/cpu_helpers.S
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 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.
+ *
+ * Neither the name of ARM nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
+ */
+
+#include <arch.h>
+#include <asm_macros.S>
+
+ .weak cpu_reset_handler
+
+
+func cpu_reset_handler
+ mov x19, x30 // lr
+
+ /* ---------------------------------------------
+ * As a bare minimal enable the SMP bit.
+ * ---------------------------------------------
+ */
+ bl read_midr
+ lsr x0, x0, #MIDR_PN_SHIFT
+ and x0, x0, #MIDR_PN_MASK
+ cmp x0, #MIDR_PN_A57
+ b.eq smp_setup_begin
+ cmp x0, #MIDR_PN_A53
+ b.ne smp_setup_end
+smp_setup_begin:
+ bl read_cpuectlr
+ orr x0, x0, #CPUECTLR_SMP_BIT
+ bl write_cpuectlr
+smp_setup_end:
+ ret x19
diff --git a/lib/arch/aarch64/misc_helpers.S b/lib/aarch64/misc_helpers.S
index e3b4ab58..e7b23313 100644
--- a/lib/arch/aarch64/misc_helpers.S
+++ b/lib/aarch64/misc_helpers.S
@@ -28,8 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch_helpers.h>
-#include <runtime_svc.h>
+#include <arch.h>
#include <asm_macros.S>
.globl enable_irq
diff --git a/lib/arch/aarch64/sysreg_helpers.S b/lib/aarch64/sysreg_helpers.S
index 8e816f03..61468f95 100644
--- a/lib/arch/aarch64/sysreg_helpers.S
+++ b/lib/aarch64/sysreg_helpers.S
@@ -28,7 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch_helpers.h>
+#include <arch.h>
#include <asm_macros.S>
.globl read_vbar_el1
diff --git a/lib/arch/aarch64/tlb_helpers.S b/lib/aarch64/tlb_helpers.S
index 42449747..ec1558b0 100644
--- a/lib/arch/aarch64/tlb_helpers.S
+++ b/lib/aarch64/tlb_helpers.S
@@ -28,7 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch_helpers.h>
#include <asm_macros.S>
.globl tlbialle1
diff --git a/lib/arch/aarch64/xlat_helpers.c b/lib/aarch64/xlat_helpers.c
index 87d24ec9..d401ffc4 100644
--- a/lib/arch/aarch64/xlat_helpers.c
+++ b/lib/aarch64/xlat_helpers.c
@@ -28,9 +28,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
-#include <assert.h>
#include <arch.h>
+#include <assert.h>
/*******************************************************************************
* Helper to create a level 1/2 table descriptor which points to a level 2/3
diff --git a/lib/arch/aarch64/xlat_tables.c b/lib/aarch64/xlat_tables.c
index 33a8b6da..6e04f65d 100644
--- a/lib/arch/aarch64/xlat_tables.c
+++ b/lib/aarch64/xlat_tables.c
@@ -61,14 +61,14 @@ static unsigned next_xlat;
* Array of all memory regions stored in order of ascending base address.
* The list is terminated by the first entry with size == 0.
*/
-static mmap_region mmap[MAX_MMAP_REGIONS + 1];
+static mmap_region_t mmap[MAX_MMAP_REGIONS + 1];
static void print_mmap(void)
{
#if DEBUG_XLAT_TABLE
debug_print("mmap:\n");
- mmap_region *mm = mmap;
+ mmap_region_t *mm = mmap;
while (mm->size) {
debug_print(" %010lx %10lx %x\n", mm->base, mm->size, mm->attr);
++mm;
@@ -79,8 +79,8 @@ static void print_mmap(void)
void mmap_add_region(unsigned long base, unsigned long size, unsigned attr)
{
- mmap_region *mm = mmap;
- mmap_region *mm_last = mm + sizeof(mmap) / sizeof(mmap[0]) - 1;
+ mmap_region_t *mm = mmap;
+ mmap_region_t *mm_last = mm + sizeof(mmap) / sizeof(mmap[0]) - 1;
assert(IS_PAGE_ALIGNED(base));
assert(IS_PAGE_ALIGNED(size));
@@ -103,7 +103,7 @@ void mmap_add_region(unsigned long base, unsigned long size, unsigned attr)
mm->attr = attr;
}
-void mmap_add(const mmap_region *mm)
+void mmap_add(const mmap_region_t *mm)
{
while (mm->size) {
mmap_add_region(mm->base, mm->size, mm->attr);
@@ -140,7 +140,7 @@ static unsigned long mmap_desc(unsigned attr, unsigned long addr,
return desc;
}
-static int mmap_region_attr(mmap_region *mm, unsigned long base,
+static int mmap_region_attr(mmap_region_t *mm, unsigned long base,
unsigned long size)
{
int attr = mm->attr;
@@ -167,7 +167,7 @@ static int mmap_region_attr(mmap_region *mm, unsigned long base,
}
}
-static mmap_region *init_xlation_table(mmap_region *mm, unsigned long base,
+static mmap_region_t *init_xlation_table(mmap_region_t *mm, unsigned long base,
unsigned long *table, unsigned level)
{
unsigned level_size_shift = L1_XLAT_ADDRESS_SHIFT - (level - 1) *
diff --git a/lib/io_storage.c b/lib/io_storage.c
index aeb8edbb..01ca1c68 100644
--- a/lib/io_storage.c
+++ b/lib/io_storage.c
@@ -28,11 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-
-#include <stddef.h>
#include <assert.h>
-#include "io_storage.h"
-#include "io_driver.h"
+#include <io_driver.h>
+#include <io_storage.h>
+#include <stddef.h>
#define MAX_DEVICES(plat_data) \
@@ -40,24 +39,24 @@
/* Storage for a fixed maximum number of IO entities, definable by platform */
-static struct io_entity entity_pool[MAX_IO_HANDLES];
+static io_entity_t entity_pool[MAX_IO_HANDLES];
/* Simple way of tracking used storage - each entry is NULL or a pointer to an
* entity */
-static struct io_entity *entity_map[MAX_IO_HANDLES];
+static io_entity_t *entity_map[MAX_IO_HANDLES];
/* Track number of allocated entities */
static unsigned int entity_count;
/* Used to keep a reference to platform-specific data */
-static struct io_plat_data *platform_data;
+static io_plat_data_t *platform_data;
#if DEBUG /* Extra validation functions only used in debug builds */
/* Return a boolean value indicating whether a device connector is valid */
-static int is_valid_dev_connector(const struct io_dev_connector *dev_con)
+static int is_valid_dev_connector(const io_dev_connector_t *dev_con)
{
int result = (dev_con != NULL) && (dev_con->dev_open != NULL);
return result;
@@ -67,7 +66,7 @@ static int is_valid_dev_connector(const struct io_dev_connector *dev_con)
/* Return a boolean value indicating whether a device handle is valid */
static int is_valid_dev(io_dev_handle handle)
{
- const struct io_dev_info *dev = handle;
+ const io_dev_info_t *dev = handle;
int result = (dev != NULL) && (dev->funcs != NULL) &&
(dev->funcs->type != NULL) &&
(dev->funcs->type() < IO_TYPE_MAX);
@@ -78,14 +77,14 @@ static int is_valid_dev(io_dev_handle handle)
/* Return a boolean value indicating whether an IO entity is valid */
static int is_valid_entity(io_handle handle)
{
- const struct io_entity *entity = handle;
+ const io_entity_t *entity = handle;
int result = (entity != NULL) && (is_valid_dev(entity->dev_handle));
return result;
}
/* Return a boolean value indicating whether a seek mode is valid */
-static int is_valid_seek_mode(io_seek_mode mode)
+static int is_valid_seek_mode(io_seek_mode_t mode)
{
return ((mode != IO_SEEK_INVALID) && (mode < IO_SEEK_MAX));
}
@@ -94,8 +93,8 @@ static int is_valid_seek_mode(io_seek_mode mode)
/* Open a connection to a specific device */
-static int dev_open(const struct io_dev_connector *dev_con, void *dev_spec,
- struct io_dev_info **dev_info)
+static int dev_open(const io_dev_connector_t *dev_con, void *dev_spec,
+ io_dev_info_t **dev_info)
{
int result = IO_FAIL;
assert(dev_info != NULL);
@@ -107,7 +106,7 @@ static int dev_open(const struct io_dev_connector *dev_con, void *dev_spec,
/* Set a handle to track an entity */
-static void set_handle(io_handle *handle, struct io_entity *entity)
+static void set_handle(io_handle *handle, io_entity_t *entity)
{
assert(handle != NULL);
*handle = entity;
@@ -217,7 +216,7 @@ int io_dev_init(struct io_dev_info *dev_handle, const void *init_params)
assert(dev_handle != NULL);
assert(is_valid_dev(dev_handle));
- struct io_dev_info *dev = dev_handle;
+ io_dev_info_t *dev = dev_handle;
if (dev->funcs->dev_init != NULL) {
result = dev->funcs->dev_init(dev, init_params);
@@ -238,7 +237,7 @@ int io_dev_close(io_dev_handle dev_handle)
assert(dev_handle != NULL);
assert(is_valid_dev(dev_handle));
- struct io_dev_info *dev = dev_handle;
+ io_dev_info_t *dev = dev_handle;
if (dev->funcs->dev_close != NULL) {
result = dev->funcs->dev_close(dev);
@@ -261,8 +260,8 @@ int io_open(io_dev_handle dev_handle, const void *spec, io_handle *handle)
assert((spec != NULL) && (handle != NULL));
assert(is_valid_dev(dev_handle));
- struct io_dev_info *dev = dev_handle;
- struct io_entity *entity;
+ io_dev_info_t *dev = dev_handle;
+ io_entity_t *entity;
result = allocate_entity(&entity);
@@ -281,14 +280,14 @@ int io_open(io_dev_handle dev_handle, const void *spec, io_handle *handle)
/* Seek to a specific position in an IO entity */
-int io_seek(io_handle handle, io_seek_mode mode, ssize_t offset)
+int io_seek(io_handle handle, io_seek_mode_t mode, ssize_t offset)
{
int result = IO_FAIL;
assert(is_valid_entity(handle) && is_valid_seek_mode(mode));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->seek != NULL)
result = dev->funcs->seek(entity, mode, offset);
@@ -305,9 +304,9 @@ int io_size(io_handle handle, size_t *length)
int result = IO_FAIL;
assert(is_valid_entity(handle) && (length != NULL));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->size != NULL)
result = dev->funcs->size(entity, length);
@@ -324,9 +323,9 @@ int io_read(io_handle handle, void *buffer, size_t length, size_t *length_read)
int result = IO_FAIL;
assert(is_valid_entity(handle) && (buffer != NULL));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->read != NULL)
result = dev->funcs->read(entity, buffer, length, length_read);
@@ -344,9 +343,9 @@ int io_write(io_handle handle, const void *buffer, size_t length,
int result = IO_FAIL;
assert(is_valid_entity(handle) && (buffer != NULL));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->write != NULL) {
result = dev->funcs->write(entity, buffer, length,
@@ -364,9 +363,9 @@ int io_close(io_handle handle)
int result = IO_FAIL;
assert(is_valid_entity(handle));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->close != NULL)
result = dev->funcs->close(entity);
diff --git a/lib/sync/locks/bakery/bakery_lock.c b/lib/locks/bakery/bakery_lock.c
index ec081352..6d4ab87b 100644
--- a/lib/sync/locks/bakery/bakery_lock.c
+++ b/lib/locks/bakery/bakery_lock.c
@@ -28,11 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <arch_helpers.h>
#include <assert.h>
-#include <string.h>
-
#include <bakery_lock.h>
-#include <arch_helpers.h>
+#include <string.h>
/*
* Functions in this file implement Bakery Algorithm for mutual exclusion.
@@ -59,14 +58,14 @@
#define assert_bakery_entry_valid(entry, bakery) do { \
assert(bakery); \
assert(entry < BAKERY_LOCK_MAX_CPUS); \
-} while(0)
+} while (0)
/* Convert a ticket to priority */
#define PRIORITY(t, pos) (((t) << 8) | (pos))
/* Initialize Bakery Lock to reset ownership and all ticket values */
-void bakery_lock_init(bakery_lock * bakery)
+void bakery_lock_init(bakery_lock_t *bakery)
{
assert(bakery);
@@ -77,7 +76,7 @@ void bakery_lock_init(bakery_lock * bakery)
/* Obtain a ticket for a given CPU */
-static unsigned int bakery_get_ticket(bakery_lock *bakery, unsigned int me)
+static unsigned int bakery_get_ticket(bakery_lock_t *bakery, unsigned int me)
{
unsigned int my_ticket, their_ticket;
unsigned int they;
@@ -124,7 +123,7 @@ static unsigned int bakery_get_ticket(bakery_lock *bakery, unsigned int me)
* of others'. The CPU with the highest priority (lowest numerical value)
* acquires the lock
*/
-void bakery_lock_get(unsigned long mpidr, bakery_lock *bakery)
+void bakery_lock_get(unsigned long mpidr, bakery_lock_t *bakery)
{
unsigned int they, me;
unsigned int my_ticket, my_prio, their_ticket;
@@ -176,7 +175,7 @@ void bakery_lock_get(unsigned long mpidr, bakery_lock *bakery)
/* Release the lock and signal contenders */
-void bakery_lock_release(unsigned long mpidr, bakery_lock * bakery)
+void bakery_lock_release(unsigned long mpidr, bakery_lock_t *bakery)
{
unsigned int me = platform_get_core_pos(mpidr);
diff --git a/lib/sync/locks/exclusive/spinlock.S b/lib/locks/exclusive/spinlock.S
index 5eae2b08..5eae2b08 100644
--- a/lib/sync/locks/exclusive/spinlock.S
+++ b/lib/locks/exclusive/spinlock.S
diff --git a/lib/semihosting/semihosting.c b/lib/semihosting/semihosting.c
index d5b8524b..1bce377c 100644
--- a/lib/semihosting/semihosting.c
+++ b/lib/semihosting/semihosting.c
@@ -29,10 +29,9 @@
*/
#include <assert.h>
-#include <string.h>
#include <errno.h>
-#include <stdio.h>
#include <semihosting.h>
+#include <string.h>
#ifndef SEMIHOSTING_SUPPORTED
#define SEMIHOSTING_SUPPORTED 1
@@ -45,23 +44,23 @@ typedef struct {
const char *file_name;
unsigned long mode;
size_t name_length;
-} smh_file_open_block;
+} smh_file_open_block_t;
typedef struct {
long handle;
void *buffer;
size_t length;
-} smh_file_read_write_block;
+} smh_file_read_write_block_t;
typedef struct {
long handle;
ssize_t location;
-} smh_file_seek_block;
+} smh_file_seek_block_t;
typedef struct {
char *command_line;
size_t command_length;
-} smh_system_block;
+} smh_system_block_t;
long semihosting_connection_supported(void)
{
@@ -70,7 +69,7 @@ long semihosting_connection_supported(void)
long semihosting_file_open(const char *file_name, size_t mode)
{
- smh_file_open_block open_block;
+ smh_file_open_block_t open_block;
open_block.file_name = file_name;
open_block.mode = mode;
@@ -82,7 +81,7 @@ long semihosting_file_open(const char *file_name, size_t mode)
long semihosting_file_seek(long file_handle, ssize_t offset)
{
- smh_file_seek_block seek_block;
+ smh_file_seek_block_t seek_block;
long result;
seek_block.handle = file_handle;
@@ -99,7 +98,7 @@ long semihosting_file_seek(long file_handle, ssize_t offset)
long semihosting_file_read(long file_handle, size_t *length, void *buffer)
{
- smh_file_read_write_block read_block;
+ smh_file_read_write_block_t read_block;
long result = -EINVAL;
if ((length == NULL) || (buffer == NULL))
@@ -125,7 +124,7 @@ long semihosting_file_write(long file_handle,
size_t *length,
const void *buffer)
{
- smh_file_read_write_block write_block;
+ smh_file_read_write_block_t write_block;
if ((length == NULL) || (buffer == NULL))
return -EINVAL;
@@ -169,7 +168,7 @@ void semihosting_write_string(char *string)
long semihosting_system(char *command_line)
{
- smh_system_block system_block;
+ smh_system_block_t system_block;
system_block.command_line = command_line;
system_block.command_length = strlen(command_line);