summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc64/shared/helenos/boot
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-23 09:57:54 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-23 15:18:44 +0200
commit142175ef7d081277efc3886dc37c807023bcdde8 (patch)
tree60b75e67813f04f3b062d003a076db50aeb3ee5d /c/src/lib/libbsp/sparc64/shared/helenos/boot
parentbsps: Move RTC drivers to bsps (diff)
downloadrtems-142175ef7d081277efc3886dc37c807023bcdde8.tar.bz2
bsps/sparc64: Move helenos to bsps
This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'c/src/lib/libbsp/sparc64/shared/helenos/boot')
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/balloc.c72
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/ofw.c464
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/ofw_tree.c255
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/boot/generic/string.c211
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/main.c441
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/ofwarch.c182
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/ofwasm.S62
7 files changed, 0 insertions, 1687 deletions
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/balloc.c b/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/balloc.c
deleted file mode 100644
index f4cb9dc1eb..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/balloc.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * 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.
- * - 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 ``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 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.
- */
-
-/*
- * Modifications are made to compile for RTEMS. Removes asm.h and replaces
- * the necessary defines in-line
- *
- */
-
-
-#include <boot/balloc.h>
-#if 0
-#include <asm.h>
-#endif
-#include <boot/types.h>
-#include <boot/align.h>
-
-static ballocs_t *ballocs;
-static uintptr_t phys_base;
-
-void balloc_init(ballocs_t *ball, uintptr_t base, uintptr_t kernel_base)
-{
- ballocs = ball;
- phys_base = base;
- ballocs->base = kernel_base;
- ballocs->size = 0;
-}
-
-void *balloc(size_t size, size_t alignment)
-{
- /* Enforce minimal alignment. */
- alignment = ALIGN_UP(alignment, 4);
-
- uintptr_t addr = phys_base + ALIGN_UP(ballocs->size, alignment);
-
- if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE)
- return NULL;
-
- ballocs->size = ALIGN_UP(ballocs->size, alignment) + size;
-
- return (void *) addr;
-}
-
-void *balloc_rebase(void *ptr)
-{
- return (void *) ((uintptr_t) ptr - phys_base + ballocs->base);
-}
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/ofw.c b/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/ofw.c
deleted file mode 100644
index 2bbc490636..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/ofw.c
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * 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.
- * - 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 ``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 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.
- */
-
-/*
- * Modifications are made to compile for RTEMS. Removes asm.h and printf.h.
- * Adds asm.h (rtems bsp). Adds ofw_read() and ofw_stdin variable. Uses
- * printk instead of puts for error messages.
- *
- */
-
-#include <bsp.h>
-#include <rtems/bspIo.h>
-
-#include <boot/ofw.h>
-#include <boot/ofwarch.h>
-#if 0
-#include <boot/printf.h>
-#include <boot/asm.h>
-#endif
-#include <boot/types.h>
-#include <string.h>
-#include <asm.h>
-
-#define RED(i) (((i) >> 5) & ((1 << 3) - 1))
-#define GREEN(i) (((i) >> 3) & ((1 << 2) - 1))
-#define BLUE(i) ((i) & ((1 << 3) - 1))
-#define CLIP(i) ((i) <= 255 ? (i) : 255)
-
-uintptr_t ofw_cif;
-
-phandle ofw_chosen;
-ihandle ofw_stdout;
-ihandle ofw_stdin;
-
-phandle ofw_root;
-ihandle ofw_mmu;
-ihandle ofw_memory_prop;
-phandle ofw_memory;
-
-void ofw_init(void)
-{
- ofw_chosen = ofw_find_device("/chosen");
- if (ofw_chosen == -1)
- halt();
-
- if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout,
- sizeof(ofw_stdout)) <= 0)
- ofw_stdout = 0;
-
- if (ofw_get_property(ofw_chosen, "stdin", &ofw_stdin,
- sizeof(ofw_stdin)) <= 0)
- ofw_stdin = 0;
-
- ofw_root = ofw_find_device("/");
- if (ofw_root == -1) {
- printk("\r\nError: Unable to find / device, halted.\r\n");
- halt();
- }
-
- if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu,
- sizeof(ofw_mmu)) <= 0) {
- printk("\r\nError: Unable to get mmu property, halted.\r\n");
- halt();
- }
- if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop,
- sizeof(ofw_memory_prop)) <= 0) {
- printk("\r\nError: Unable to get memory property, halted.\r\n");
- halt();
- }
-
- ofw_memory = ofw_find_device("/memory");
- if (ofw_memory == -1) {
- printk("\r\nError: Unable to find /memory device, halted.\r\n");
- halt();
- }
-}
-
-/** Perform a call to OpenFirmware client interface.
- *
- * @param service String identifying the service requested.
- * @param nargs Number of input arguments.
- * @param nret Number of output arguments. This includes the return
- * value.
- * @param rets Buffer for output arguments or NULL. The buffer must
- * accommodate nret - 1 items.
- *
- * @return Return value returned by the client interface.
- *
- */
-unsigned long
-ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets,
- ...)
-{
- va_list list;
- ofw_args_t args;
- int i;
-
- args.service = (ofw_arg_t) service;
- args.nargs = nargs;
- args.nret = nret;
-
- va_start(list, rets);
- for (i = 0; i < nargs; i++)
- args.args[i] = va_arg(list, ofw_arg_t);
- va_end(list);
-
- for (i = 0; i < nret; i++)
- args.args[i + nargs] = 0;
-
- (void) ofw(&args);
-
- for (i = 1; i < nret; i++)
- rets[i - 1] = args.args[i + nargs];
-
- return args.args[nargs];
-}
-
-phandle ofw_find_device(const char *name)
-{
- return ofw_call("finddevice", 1, 1, NULL, name);
-}
-
-int ofw_get_property(const phandle device, const char *name, void *buf,
- const int buflen)
-{
- return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
-}
-
-int ofw_get_proplen(const phandle device, const char *name)
-{
- return ofw_call("getproplen", 2, 1, NULL, device, name);
-}
-
-int ofw_next_property(const phandle device, char *previous, char *buf)
-{
- return ofw_call("nextprop", 3, 1, NULL, device, previous, buf);
-}
-
-int ofw_package_to_path(const phandle device, char *buf, const int buflen)
-{
- return ofw_call("package-to-path", 3, 1, NULL, device, buf, buflen);
-}
-
-unsigned int ofw_get_address_cells(const phandle device)
-{
- unsigned int ret = 1;
-
- if (ofw_get_property(device, "#address-cells", &ret, sizeof(ret)) <= 0)
- if (ofw_get_property(ofw_root, "#address-cells", &ret,
- sizeof(ret)) <= 0)
- ret = OFW_ADDRESS_CELLS;
-
- return ret;
-}
-
-unsigned int ofw_get_size_cells(const phandle device)
-{
- unsigned int ret;
-
- if (ofw_get_property(device, "#size-cells", &ret, sizeof(ret)) <= 0)
- if (ofw_get_property(ofw_root, "#size-cells", &ret,
- sizeof(ret)) <= 0)
- ret = OFW_SIZE_CELLS;
-
- return ret;
-}
-
-phandle ofw_get_child_node(const phandle node)
-{
- return ofw_call("child", 1, 1, NULL, node);
-}
-
-phandle ofw_get_peer_node(const phandle node)
-{
- return ofw_call("peer", 1, 1, NULL, node);
-}
-
-static ihandle ofw_open(const char *name)
-{
- return ofw_call("open", 1, 1, NULL, name);
-}
-
-
-void ofw_write(const char *str, const int len)
-{
- if (ofw_stdout == 0)
- return;
-
- ofw_call("write", 3, 1, NULL, ofw_stdout, str, len);
-}
-
-void ofw_read(void *str, const int len)
-{
- if (ofw_stdin == 0)
- return;
-
- ofw_call("read", 3, 1, NULL, ofw_stdin, str, len);
-}
-
-void *ofw_translate(const void *virt)
-{
- ofw_arg_t result[4];
- int shift;
-
- if (ofw_call("call-method", 4, 5, result, "translate", ofw_mmu,
- virt, 0) != 0) {
- printk("Error: MMU method translate() failed, halting.\n");
- halt();
- }
-
- if (ofw_translate_failed(result[0]))
- return NULL;
-
- if (sizeof(unative_t) == 8)
- shift = 32;
- else
- shift = 0;
-
- return (void *) ((result[2] << shift) | result[3]);
-}
-
-void *ofw_claim_virt(const void *virt, const unsigned int len)
-{
- ofw_arg_t retaddr;
-
- if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len,
- virt) != 0) {
- printk("Error: MMU method claim() failed, halting.\n");
- halt();
- }
-
- return (void *) retaddr;
-}
-
-static void *ofw_claim_phys_internal(const void *phys, const unsigned int len, const unsigned int alignment)
-{
- /*
- * Note that the return value check will help
- * us to discover conflicts between OpenFirmware
- * allocations and our use of physical memory.
- * It is better to detect collisions here
- * than to cope with weird errors later.
- *
- * So this is really not to make the loader
- * more generic; it is here for debugging
- * purposes.
- */
-
- if (sizeof(unative_t) == 8) {
- ofw_arg_t retaddr[2];
- int shift = 32;
-
- if (ofw_call("call-method", 6, 3, retaddr, "claim",
- ofw_memory_prop, alignment, len, ((uintptr_t) phys) >> shift,
- ((uintptr_t) phys) & ((uint32_t) -1)) != 0) {
- printk("Error: memory method claim() failed, halting.\n");
- halt();
- }
-
- return (void *) ((retaddr[0] << shift) | retaddr[1]);
- } else {
- ofw_arg_t retaddr[1];
-
- if (ofw_call("call-method", 5, 2, retaddr, "claim",
- ofw_memory_prop, alignment, len, (uintptr_t) phys) != 0) {
- printk("Error: memory method claim() failed, halting.\n");
- halt();
- }
-
- return (void *) retaddr[0];
- }
-}
-
-void *ofw_claim_phys(const void *phys, const unsigned int len)
-{
- return ofw_claim_phys_internal(phys, len, 0);
-}
-
-void *ofw_claim_phys_any(const unsigned int len, const unsigned int alignment)
-{
- return ofw_claim_phys_internal(NULL, len, alignment);
-}
-
-int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode)
-{
- uintptr_t phys_hi, phys_lo;
-
- if (sizeof(unative_t) == 8) {
- int shift = 32;
- phys_hi = (uintptr_t) phys >> shift;
- phys_lo = (uintptr_t) phys & 0xffffffff;
- } else {
- phys_hi = 0;
- phys_lo = (uintptr_t) phys;
- }
-
- return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size,
- virt, phys_hi, phys_lo);
-}
-
-/** Save OpenFirmware physical memory map.
- *
- * @param map Memory map structure where the map will be saved.
- *
- * @return Zero on failure, non-zero on success.
- */
-int ofw_memmap(memmap_t *map)
-{
- unsigned int ac = ofw_get_address_cells(ofw_memory) /
- (sizeof(uintptr_t) / sizeof(uint32_t));
- unsigned int sc = ofw_get_size_cells(ofw_memory) /
- (sizeof(uintptr_t) / sizeof(uint32_t));
-
- uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)];
- int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
- if (ret <= 0) /* ret is the number of written bytes */
- return false;
-
- int pos;
- map->total = 0;
- map->count = 0;
- for (pos = 0; (pos < ret / sizeof(uintptr_t)) &&
- (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
- void *start = (void *) (buf[pos + ac - 1]);
- unsigned int size = buf[pos + ac + sc - 1];
-
- /*
- * This is a hot fix of the issue which occurs on machines
- * where there are holes in the physical memory (such as
- * SunBlade 1500). Should we detect a hole in the physical
- * memory, we will ignore any memory detected behind
- * the hole and pretend the hole does not exist.
- */
- if ((map->count > 0) && (map->zones[map->count - 1].start +
- map->zones[map->count - 1].size < start))
- break;
-
- if (size > 0) {
- map->zones[map->count].start = start;
- map->zones[map->count].size = size;
- map->count++;
- map->total += size;
- }
- }
-
- return true;
-}
-
-static void ofw_setup_screen(phandle handle)
-{
- /* Check for device type */
- char device_type[OFW_TREE_PROPERTY_MAX_VALUELEN];
- if (ofw_get_property(handle, "device_type", device_type, OFW_TREE_PROPERTY_MAX_VALUELEN) <= 0)
- return;
-
- device_type[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = '\0';
- if (strcmp(device_type, "display") != 0)
- return;
-
- /* Check for 8 bit depth */
- uint32_t depth;
- if (ofw_get_property(handle, "depth", &depth, sizeof(uint32_t)) <= 0)
- depth = 0;
-
- /* Get device path */
- static char path[OFW_TREE_PATH_MAX_LEN + 1];
- size_t len = ofw_package_to_path(handle, path, OFW_TREE_PATH_MAX_LEN);
- if (len == -1)
- return;
-
- path[len] = '\0';
-
- /* Open the display to initialize it */
- ihandle screen = ofw_open(path);
- if (screen == -1)
- return;
-
- if (depth == 8) {
- /* Setup the palette so that the (inverted) 3:2:3 scheme is usable */
- unsigned int i;
- for (i = 0; i < 256; i++) {
- ofw_call("call-method", 6, 1, NULL, "color!", screen,
- 255 - i, CLIP(BLUE(i) * 37), GREEN(i) * 85, CLIP(RED(i) * 37));
- }
- }
-}
-
-static void ofw_setup_screens_internal(phandle current)
-{
- while ((current != 0) && (current != -1)) {
- ofw_setup_screen(current);
-
- /*
- * Recursively process the potential child node.
- */
- phandle child = ofw_get_child_node(current);
- if ((child != 0) && (child != -1))
- ofw_setup_screens_internal(child);
-
- /*
- * Iteratively process the next peer node.
- * Note that recursion is a bad idea here.
- * Due to the topology of the OpenFirmware device tree,
- * the nesting of peer nodes could be to wide and the
- * risk of overflowing the stack is too real.
- */
- phandle peer = ofw_get_peer_node(current);
- if ((peer != 0) && (peer != -1)) {
- current = peer;
- /*
- * Process the peer in next iteration.
- */
- continue;
- }
-
- /*
- * No more peers on this level.
- */
- break;
- }
-}
-
-/** Setup all screens which can be detected.
- *
- * Open all screens which can be detected and set up the palette for the 8-bit
- * color depth configuration so that the 3:2:3 color scheme can be used.
- * Check that setting the palette makes sense (the color depth is not greater
- * than 8).
- *
- */
-void ofw_setup_screens(void)
-{
- ofw_setup_screens_internal(ofw_root);
-}
-
-void ofw_quiesce(void)
-{
- ofw_call("quiesce", 0, 0, NULL);
-}
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/ofw_tree.c b/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/ofw_tree.c
deleted file mode 100644
index d6770c093d..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/boot/genarch/ofw_tree.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * 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.
- * - 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 ``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 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.
- */
-
-/*
- * Modifications are made to compile for RTEMS. Removes asm.h and memstr.h.
- *
- */
-
-
-#include <boot/ofw_tree.h>
-#include <boot/ofw.h>
-#include <boot/ofwarch.h>
-#include <boot/types.h>
-#include <string.h>
-#include <boot/balloc.h>
-#if 0
-#include <asm.h>
-#include <memstr.h>
-#endif
-
-static ofw_tree_node_t *ofw_tree_node_alloc(void)
-{
- return balloc(sizeof(ofw_tree_node_t), sizeof(ofw_tree_node_t));
-}
-
-static ofw_tree_property_t *ofw_tree_properties_alloc(unsigned count)
-{
- return balloc(count * sizeof(ofw_tree_property_t),
- sizeof(ofw_tree_property_t));
-}
-
-static void *ofw_tree_space_alloc(size_t size)
-{
- /*
- * What we do here is a nasty hack :-)
- * Problem: string property values that are allocated via this
- * function typically do not contain the trailing '\0'. This
- * is very uncomfortable for kernel, which is supposed to deal
- * with the properties.
- * Solution: when allocating space via this function, we always
- * allocate space for the extra '\0' character that we store
- * behind the requested memory.
- */
- char *addr = balloc(size + 1, size);
- if (addr)
- addr[size] = '\0';
-
- return addr;
-}
-
-/** Transfer information from one OpenFirmware node into its memory
- * representation.
- *
- * Transfer entire information from the OpenFirmware device tree 'current' node
- * to its memory representation in 'current_node'. This function recursively
- * processes all node's children. Node's peers are processed iteratively in
- * order to prevent stack from overflowing.
- *
- * @param current_node Pointer to uninitialized ofw_tree_node structure that
- * will become the memory represenation of 'current'.
- * @param parent_node Parent ofw_tree_node structure or NULL in case of root
- * node.
- * @param current OpenFirmware phandle to the current device tree node.
- *
- */
-static void ofw_tree_node_process(ofw_tree_node_t *current_node,
- ofw_tree_node_t *parent_node, phandle current)
-{
- while (current_node) {
- /*
- * Initialize node.
- */
- current_node->parent = (ofw_tree_node_t *) balloc_rebase(parent_node);
- current_node->peer = NULL;
- current_node->child = NULL;
- current_node->node_handle = current;
- current_node->properties = 0;
- current_node->property = NULL;
- current_node->device = NULL;
-
- /*
- * Get the disambigued name.
- */
- static char path[OFW_TREE_PATH_MAX_LEN + 1];
- size_t len = ofw_package_to_path(current, path, OFW_TREE_PATH_MAX_LEN);
- if (len == -1)
- return;
-
- path[len] = '\0';
-
- /* Find last slash */
- int i;
- for (i = len - 1; (i >= 0) && (path[i] != '/'); i--);
-
- /* Do not include the slash */
- i++;
- len -= i;
-
- /* Add space for trailing '\0' */
- char *da_name = ofw_tree_space_alloc(len + 1);
- if (!da_name)
- return;
-
- memcpy(da_name, &path[i], len);
- da_name[len] = '\0';
- current_node->da_name = (char *) balloc_rebase(da_name);
-
- /*
- * Recursively process the potential child node.
- */
- phandle child = ofw_get_child_node(current);
- if ((child != 0) && (child != -1)) {
- ofw_tree_node_t *child_node = ofw_tree_node_alloc();
- if (child_node) {
- ofw_tree_node_process(child_node, current_node,
- child);
- current_node->child =
- (ofw_tree_node_t *) balloc_rebase(child_node);
- }
- }
-
- /*
- * Count properties.
- */
- static char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
- static char name2[OFW_TREE_PROPERTY_MAX_NAMELEN];
- name[0] = '\0';
- while (ofw_next_property(current, name, name2) == 1) {
- current_node->properties++;
- memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN);
- }
-
- if (!current_node->properties)
- return;
-
- /*
- * Copy properties.
- */
- ofw_tree_property_t *property =
- ofw_tree_properties_alloc(current_node->properties);
- if (!property)
- return;
-
- name[0] = '\0';
- for (i = 0; ofw_next_property(current, name, name2) == 1; i++) {
- if (i == current_node->properties)
- break;
-
- memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN);
- memcpy(property[i].name, name, OFW_TREE_PROPERTY_MAX_NAMELEN);
- property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN - 1] = '\0';
-
- size_t size = ofw_get_proplen(current, name);
- property[i].size = size;
-
- if (size) {
- void *buf = ofw_tree_space_alloc(size);
- if (buf) {
- /*
- * Copy property value to memory node.
- */
- (void) ofw_get_property(current, name, buf, size);
- property[i].value = balloc_rebase(buf);
- }
- } else
- property[i].value = NULL;
- }
-
- /* Just in case we ran out of memory. */
- current_node->properties = i;
- current_node->property = (ofw_tree_property_t *) balloc_rebase(property);
-
-
- /*
- * Iteratively process the next peer node.
- * Note that recursion is a bad idea here.
- * Due to the topology of the OpenFirmware device tree,
- * the nesting of peer nodes could be to wide and the
- * risk of overflowing the stack is too real.
- */
- phandle peer = ofw_get_peer_node(current);
- if ((peer != 0) && (peer != -1)) {
- ofw_tree_node_t *peer_node = ofw_tree_node_alloc();
- if (peer_node) {
- current_node->peer = (ofw_tree_node_t *) balloc_rebase(peer_node);
- current_node = peer_node;
- current = peer;
- /*
- * Process the peer in next iteration.
- */
- continue;
- }
- }
-
- /*
- * No more peers on this level.
- */
- break;
- }
-}
-
-/** Construct memory representation of OpenFirmware device tree.
- *
- * @return NULL on failure or kernel pointer to the root node.
- *
- */
-ofw_tree_node_t *ofw_tree_build(void)
-{
- ofw_tree_node_t *root = ofw_tree_node_alloc();
- if (root)
- ofw_tree_node_process(root, NULL, ofw_root);
-
- /*
- * The firmware client interface does not automatically include the
- * "ssm" node in the list of children of "/". A nasty yet working
- * solution is to explicitly stick "ssm" to the OFW tree.
- */
- phandle ssm_node = ofw_find_device("/ssm@0,0");
- if (ssm_node != -1) {
- ofw_tree_node_t *ssm = ofw_tree_node_alloc();
- if (ssm) {
- ofw_tree_node_process(ssm, root,
- ofw_find_device("/ssm@0,0"));
- ssm->peer = root->child;
- root->child = (ofw_tree_node_t *) balloc_rebase(ssm);
- }
- }
-
- return (ofw_tree_node_t *) balloc_rebase(root);
-}
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/boot/generic/string.c b/c/src/lib/libbsp/sparc64/shared/helenos/boot/generic/string.c
deleted file mode 100644
index ad6d1b7284..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/boot/generic/string.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Jakub Jermar
- * 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.
- * - 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 ``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 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.
- */
-
-/** @addtogroup generic
- * @{
- */
-
-/*
- * Modifications are made to compile for RTEMS. Remove strncpy() and atoi()
- *
- */
-
-
-#include <string.h>
-
-/**
- * @file
- * @brief String manipulation functions.
- */
-
-/** Return number of characters in a string.
- *
- * @param str NULL terminated string.
- *
- * @return Number of characters in str.
- */
-size_t strlen(const char *str)
-{
- int i;
-
- for (i = 0; str[i]; i++)
- ;
-
- return i;
-}
-
-/** Compare two NULL terminated strings.
- *
- * Do a char-by-char comparison of two NULL terminated strings.
- * The strings are considered equal iff they consist of the same
- * characters on the minimum of their lengths.
- *
- * @param src First string to compare.
- * @param dst Second string to compare.
- *
- * @return 0 if the strings are equal, -1 if first is smaller,
- * 1 if second smaller.
- *
- */
-int strcmp(const char *src, const char *dst)
-{
- for (; *src && *dst; src++, dst++) {
- if (*src < *dst)
- return -1;
- if (*src > *dst)
- return 1;
- }
- if (*src == *dst)
- return 0;
- if (!*src)
- return -1;
- return 1;
-}
-
-
-/** Compare two NULL terminated strings.
- *
- * Do a char-by-char comparison of two NULL terminated strings.
- * The strings are considered equal iff they consist of the same
- * characters on the minimum of their lengths and specified maximal
- * length.
- *
- * @param src First string to compare.
- * @param dst Second string to compare.
- * @param len Maximal length for comparison.
- *
- * @return 0 if the strings are equal, -1 if first is smaller,
- * 1 if second smaller.
- *
- */
-int strncmp(const char *src, const char *dst, size_t len)
-{
- int i;
-
- for (i = 0; *src && *dst && i < len; src++, dst++, i++) {
- if (*src < *dst)
- return -1;
- if (*src > *dst)
- return 1;
- }
- if (i == len || *src == *dst)
- return 0;
- if (!*src)
- return -1;
- return 1;
-}
-#if 0
-/** Copy NULL terminated string.
- *
- * Copy at most 'len' characters from string 'src' to 'dest'.
- * If 'src' is shorter than 'len', '\0' is inserted behind the
- * last copied character.
- *
- * @param src Source string.
- * @param dest Destination buffer.
- * @param len Size of destination buffer.
- */
-void strncpy(char *dest, const char *src, size_t len)
-{
- int i;
- for (i = 0; i < len; i++) {
- if (!(dest[i] = src[i]))
- return;
- }
- dest[i-1] = '\0';
-}
-
-/** Convert ascii representation to unative_t.
- *
- * Supports 0x for hexa & 0 for octal notation.
- * Does not check for overflows, does not support negative numbers
- *
- * @param text Textual representation of number.
- * @return Converted number or 0 if no valid number found.
- */
-unative_t atoi(const char *text)
-{
- int base = 10;
- unative_t result = 0;
-
- if (text[0] == '0' && text[1] == 'x') {
- base = 16;
- text += 2;
- } else if (text[0] == '0')
- base = 8;
-
- while (*text) {
- if (base != 16 &&
- ((*text >= 'A' && *text <= 'F') ||
- (*text >='a' && *text <='f')))
- break;
- if (base == 8 && *text >='8')
- break;
-
- if (*text >= '0' && *text <= '9') {
- result *= base;
- result += *text - '0';
- } else if (*text >= 'A' && *text <= 'F') {
- result *= base;
- result += *text - 'A' + 10;
- } else if (*text >= 'a' && *text <= 'f') {
- result *= base;
- result += *text - 'a' + 10;
- } else
- break;
- text++;
- }
-
- return result;
-}
-#endif
-/** Move piece of memory to another, possibly overlapping, location.
- *
- * @param dst Destination address.
- * @param src Source address.
- * @param len Number of bytes to move.
- *
- * @return Destination address.
- */
-void *memmove(void *dst, const void *src, size_t len)
-{
- char *d = dst;
- const char *s = src;
- if (s < d) {
- while (len--)
- *(d + len) = *(s + len);
- } else {
- while (len--)
- *d++ = *s++;
- }
-
- return dst;
-}
-
-/** @}
- */
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/main.c b/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/main.c
deleted file mode 100644
index 75579ed44c..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/main.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * Copyright (c) 2006 Jakub Jermar
- * 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.
- * - 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 ``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 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.
- */
-
-/*
- * Modifications are made to switch to using printk rather than printf,
- * and to remove portions of the HelenOS bootstrap process that are
- * unnecessary on RTEMS. The removed code is elided with #if 0 ... #endif
- * blocks.
- *
- * Removes some header files. Adds back some missing defines.
- */
-
-#define RTEMS
-
-#include <bsp.h>
-#include <rtems/bspIo.h>
-#include <inttypes.h>
-#include <string.h>
-
-#include <boot/main.h>
-#include <boot/balloc.h>
-#include <boot/ofw.h>
-#include <boot/ofw_tree.h>
-#include <boot/ofwarch.h>
-#include <boot/align.h>
-
-#if 0
-#include "asm.h"
-#include <printf.h>
-#include "_components.h"
-#include <macros.h>
-#include <string.h>
-#include <memstr.h>
-#endif
-
-#include <asm.h>
-
-#if 0
-#define PAGE_WIDTH 14
-#define PAGE_SIZE (1 << PAGE_WIDTH)
-#endif
-
-static bootinfo_t bootinfo;
-#if 0
-static component_t components[COMPONENTS];
-static char *release = STRING(RELEASE);
-
-#ifdef REVISION
- static char *revision = ", revision " STRING(REVISION);
-#else
- static char *revision = "";
-#endif
-
-#ifdef TIMESTAMP
- static char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
-#else
- static char *timestamp = "";
-#endif
-#endif
-
-#if 0
-/** UltraSPARC subarchitecture - 1 for US, 3 for US3, 0 for other */
-static uint8_t subarchitecture = 0;
-#endif
-
-#if 0
-/**
- * mask of the MID field inside the ICBUS_CONFIG register shifted by
- * MID_SHIFT bits to the right
- */
-static uint16_t mid_mask;
-#endif
-
-#if 0
-/** Print version information. */
-static void version_print(void)
-{
- printk("HelenOS SPARC64 Bootloader\nRelease %s%s%s\n"
- "Copyright (c) 2006 HelenOS project\n",
- release, revision, timestamp);
-}
-#endif
-
-/* the lowest ID (read from the VER register) of some US3 CPU model */
-#define FIRST_US3_CPU 0x14
-
-/* the greatest ID (read from the VER register) of some US3 CPU model */
-#define LAST_US3_CPU 0x19
-
-/* UltraSPARC IIIi processor implementation code */
-#define US_IIIi_CODE 0x15
-
-/* max. length of the "compatible" property of the root node */
-#define COMPATIBLE_PROP_MAXLEN 64
-
-/*
- * HelenOS bootloader will use these constants to distinguish particular
- * UltraSPARC architectures
- */
-#define COMPATIBLE_SUN4U 10
-#define COMPATIBLE_SUN4V 20
-
-/** US architecture. COMPATIBLE_SUN4U for sun4v, COMPATIBLE_SUN4V for sun4u */
-static uint8_t architecture;
-
-/**
- * Detects the UltraSPARC architecture (sun4u and sun4v currently supported)
- * by inspecting the property called "compatible" in the OBP root node.
- */
-static void detect_architecture(void)
-{
- phandle root = ofw_find_device("/");
- char compatible[COMPATIBLE_PROP_MAXLEN];
-
- if (ofw_get_property(root, "compatible", compatible,
- COMPATIBLE_PROP_MAXLEN) <= 0) {
- printk("Unable to determine architecture, default: sun4u.\n");
- architecture = COMPATIBLE_SUN4U;
- return;
- }
-
- if (strcmp(compatible, "sun4v") == 0) {
- architecture = COMPATIBLE_SUN4V;
- } else {
- /*
- * As not all sun4u machines have "sun4u" in their "compatible"
- * OBP property (e.g. Serengeti's OBP "compatible" property is
- * "SUNW,Serengeti"), we will by default fallback to sun4u if
- * an unknown value of the "compatible" property is encountered.
- */
- architecture = COMPATIBLE_SUN4U;
- }
-}
-
-#if 0
-/**
- * Detects the subarchitecture (US, US3) of the sun4u
- * processor. Sets the global variables "subarchitecture" and "mid_mask" to
- * correct values.
- */
-static void detect_subarchitecture(void)
-{
- uint64_t v;
- asm volatile (
- "rdpr %%ver, %0\n"
- : "=r" (v)
- );
-
- v = (v << 16) >> 48;
- if ((v >= FIRST_US3_CPU) && (v <= LAST_US3_CPU)) {
- subarchitecture = SUBARCH_US3;
- if (v == US_IIIi_CODE)
- mid_mask = (1 << 5) - 1;
- else
- mid_mask = (1 << 10) - 1;
- } else if (v < FIRST_US3_CPU) {
- subarchitecture = SUBARCH_US;
- mid_mask = (1 << 5) - 1;
- } else
- printk("\nThis CPU is not supported by HelenOS.");
-}
-#endif
-
-#if 0
-/**
- * Performs sun4u-specific initialization. The components are expected
- * to be already copied and boot allocator initialized.
- *
- * @param base kernel base virtual address
- * @param top virtual address above which the boot allocator
- * can make allocations
- */
-static void bootstrap_sun4u(void *base, unsigned int top)
-{
- void *balloc_base;
- /*
- * Claim and map the physical memory for the boot allocator.
- * Initialize the boot allocator.
- */
- balloc_base = base + ALIGN_UP(top, PAGE_SIZE);
- (void) ofw_claim_phys(bootinfo.physmem_start + balloc_base,
- BALLOC_MAX_SIZE);
- (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base,
- BALLOC_MAX_SIZE, -1);
- balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base,
- (uintptr_t) balloc_base);
-#if 0
- printf("Setting up screens...");
- ofw_setup_screens();
- printf("done.\n");
-#endif
-#if 0
- printf("Canonizing OpenFirmware device tree...");
-#endif
- bootinfo.ofw_root = ofw_tree_build();
-#if 0
- printf("done.\n");
-#endif
-#if 0
-#ifdef CONFIG_AP
- printf("Checking for secondary processors...");
- if (!ofw_cpu(mid_mask, bootinfo.physmem_start))
- printf("Error: unable to get CPU properties\n");
- printf("done.\n");
-#endif
-#endif
-}
-#endif
-
-#if 0
-/**
- * * Performs sun4v-specific initialization. The components are expected
- * * to be already copied and boot allocator initialized.
- * */
-static void bootstrap_sun4v(void)
-{
- /*
- * When SILO booted, the OBP had established a virtual to physical
- * memory mapping. This mapping is not an identity (because the
- * physical memory starts on non-zero address) - this is not
- * surprising. But! The mapping even does not map virtual address
- * 0 onto the starting address of the physical memory, but onto an
- * address which is 0x400000 bytes higher. The reason is that the
- * OBP had already used the memory just at the beginning of the
- * physical memory, so that memory cannot be used by SILO (nor
- * bootloader). As for now, we solve it by a nasty workaround:
- * we pretend that the physical memory starts 0x400000 bytes further
- * than it actually does (and hence pretend that the physical memory
- * is 0x400000 bytes smaller). Of course, the value 0x400000 will most
- * probably depend on the machine and OBP version (the workaround now
- * works on Simics). A solution would be to inspect the "available"
- * property of the "/memory" node to find out which parts of memory
- * are used by OBP and redesign the algorithm of copying
- * kernel/init tasks/ramdisk from the bootable image to memory
- * (which we must do anyway because of issues with claiming the memory
- * on Serengeti).
- */
- bootinfo.physmem_start += 0x400000;
- bootinfo.memmap.zones[0].start += 0x400000;
- bootinfo.memmap.zones[0].size -= 0x400000;
-#if 0
- printf("The sun4v init finished.");
-#endif
-}
-#endif
-
-void bootstrap(void)
-{
-#if 0
- void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
- unsigned int top = 0;
- unsigned int i;
- unsigned int j;
-#endif
-
- detect_architecture();
-#if 0
- init_components(components);
-#endif
-
- if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
- printk("Error: unable to get start of physical memory.\n");
- halt();
- }
-
- if (!ofw_memmap(&bootinfo.memmap)) {
- printk("Error: unable to get memory map, halting.\n");
- halt();
- }
-
- if (bootinfo.memmap.total == 0) {
- printk("Error: no memory detected, halting.\n");
- halt();
- }
-
- /*
- * SILO for some reason adds 0x400000 and subtracts
- * bootinfo.physmem_start to/from silo_ramdisk_image.
- * We just need plain physical address so we fix it up.
- */
- if (silo_ramdisk_image) {
- silo_ramdisk_image += bootinfo.physmem_start;
- silo_ramdisk_image -= 0x400000;
-
- /* Install 1:1 mapping for the RAM disk. */
- if (ofw_map((void *) ((uintptr_t) silo_ramdisk_image),
- (void *) ((uintptr_t) silo_ramdisk_image),
- silo_ramdisk_size, -1) != 0) {
- printk("Failed to map RAM disk.\n");
- halt();
- }
- }
-
- printk("\nMemory statistics (total %d MB, starting at %" PRIxPTR ")\n",
- bootinfo.memmap.total >> 20, bootinfo.physmem_start);
- printk(" %x: kernel entry point\n", KERNEL_VIRTUAL_ADDRESS);
- printk(" %p: boot info structure\n", &bootinfo);
-
-#if 0
- /*
- * Figure out destination address for each component.
- * In this phase, we don't copy the components yet because we want to
- * to be careful not to overwrite anything, especially the components
- * which haven't been copied yet.
- */
- bootinfo.taskmap.count = 0;
- for (i = 0; i < COMPONENTS; i++) {
- printf(" %P: %s image (size %d bytes)\n", components[i].start,
- components[i].name, components[i].size);
- top = ALIGN_UP(top, PAGE_SIZE);
- if (i > 0) {
- if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) {
- printf("Skipping superfluous components.\n");
- break;
- }
-
- bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
- base + top;
- bootinfo.taskmap.tasks[bootinfo.taskmap.count].size =
- components[i].size;
- strncpy(bootinfo.taskmap.tasks[
- bootinfo.taskmap.count].name, components[i].name,
- BOOTINFO_TASK_NAME_BUFLEN);
- bootinfo.taskmap.count++;
- }
- top += components[i].size;
- }
-
- printf("\n");
-
- /* Do not consider RAM disk */
- j = bootinfo.taskmap.count - 1;
-
- if (silo_ramdisk_image) {
- /* Treat the RAM disk as the last bootinfo task. */
- if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) {
- printf("Skipping RAM disk.\n");
- goto skip_ramdisk;
- }
-
- top = ALIGN_UP(top, PAGE_SIZE);
- bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
- base + top;
- bootinfo.taskmap.tasks[bootinfo.taskmap.count].size =
- silo_ramdisk_size;
- bootinfo.taskmap.count++;
- printf("Copying RAM disk...");
-
- /*
- * Claim and map the whole ramdisk as it may exceed the area
- * given to us by SILO.
- */
- (void) ofw_claim_phys(base + top, silo_ramdisk_size);
- (void) ofw_map(bootinfo.physmem_start + base + top, base + top,
- silo_ramdisk_size, -1);
- memmove(base + top, (void *) ((uintptr_t) silo_ramdisk_image),
- silo_ramdisk_size);
-
- printf("done.\n");
- top += silo_ramdisk_size;
- }
-skip_ramdisk:
-
- /*
- * Now we can proceed to copy the components. We do it in reverse order
- * so that we don't overwrite anything even if the components overlap
- * with base.
- */
- printf("Copying tasks...");
- for (i = COMPONENTS - 1; i > 0; i--, j--) {
- printf("%s ", components[i].name);
-
- /*
- * At this point, we claim the physical memory that we are
- * going to use. We should be safe in case of the virtual
- * address space because the OpenFirmware, according to its
- * SPARC binding, should restrict its use of virtual memory
- * to addresses from [0xffd00000; 0xffefffff] and
- * [0xfe000000; 0xfeffffff].
- *
- * XXX We don't map this piece of memory. We simply rely on
- * SILO to have it done for us already in this case.
- */
- (void) ofw_claim_phys(bootinfo.physmem_start +
- bootinfo.taskmap.tasks[j].addr,
- ALIGN_UP(components[i].size, PAGE_SIZE));
-
- memcpy((void *) bootinfo.taskmap.tasks[j].addr,
- components[i].start, components[i].size);
-
- }
- printf(".\n");
-
- printf("Copying kernel...");
- (void) ofw_claim_phys(bootinfo.physmem_start + base,
- ALIGN_UP(components[0].size, PAGE_SIZE));
- memcpy(base, components[0].start, components[0].size);
- printf("done.\n");
-
- /* perform architecture-specific initialization */
- if (architecture == COMPATIBLE_SUN4U) {
- bootstrap_sun4u(base, top);
- } else if (architecture == COMPATIBLE_SUN4V) {
- bootstrap_sun4v();
- } else {
- printf("Unknown architecture.\n");
- halt();
- }
-
- printf("Booting the kernel...\n");
- jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
- bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,
- sizeof(bootinfo), subarchitecture);
-#endif
-}
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/ofwarch.c b/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/ofwarch.c
deleted file mode 100644
index 318b4dc305..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/ofwarch.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * Copyright (c) 2006 Jakub Jermar
- * 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.
- * - 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 ``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 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.
- */
-
-/**
- * @file
- * @brief Architecture dependent parts of OpenFirmware interface.
- */
-
-/*
- * Modifications are made to compile for RTEMS. Removes asm.h and printf.h.
- * Removes write().
- *
- */
-
-
-#include <boot/ofwarch.h>
-#include <boot/ofw.h>
-#include <string.h>
-#include <boot/register.h>
-#include <boot/main.h>
-#if 0
-#include "asm.h"
-#include <printf.h>
-#endif
-
-#if 0 /* contaminates libc */
-void write(const char *str, const int len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- if (str[i] == '\n')
- ofw_write("\r", 1);
- ofw_write(&str[i], 1);
- }
-}
-#endif
-
-int ofw_translate_failed(ofw_arg_t flag)
-{
- return flag != -1;
-}
-
-/**
- * Starts all CPUs represented by following siblings of the given node,
- * except for the current CPU.
- *
- * @param child The first child of the OFW tree node whose children
- * represent CPUs to be woken up.
- * @param current_mid MID of the current CPU, the current CPU will
- * (of course) not be woken up.
- * @param physmem_start Starting address of the physical memory.
- *
- * @return Number of CPUs which have the same parent node as
- * "child".
- *
- */
-static int wake_cpus_in_node(phandle child, uint64_t current_mid,
- uintptr_t physmem_start)
-{
- int cpus;
-
- for (cpus = 0; (child != 0) && (child != -1);
- child = ofw_get_peer_node(child), cpus++) {
- char type_name[OFW_TREE_PROPERTY_MAX_VALUELEN];
-
- if (ofw_get_property(child, "device_type", type_name,
- OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) {
- type_name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0;
- if (strcmp(type_name, "cpu") == 0) {
- uint32_t mid;
-
- /*
- * "upa-portid" for US, "portid" for US-III,
- * "cpuid" for US-IV
- */
- if ((ofw_get_property(child, "upa-portid", &mid, sizeof(mid)) <= 0)
- && (ofw_get_property(child, "portid", &mid, sizeof(mid)) <= 0)
- && (ofw_get_property(child, "cpuid", &mid, sizeof(mid)) <= 0))
- continue;
-
- if (current_mid != mid) {
- /*
- * Start secondary processor.
- */
- (void) ofw_call("SUNW,start-cpu", 3, 1,
- NULL, child, KERNEL_VIRTUAL_ADDRESS,
- physmem_start | AP_PROCESSOR);
- }
- }
- }
- }
-
- return cpus;
-}
-
-/**
- * Finds out the current CPU's MID and wakes up all AP processors.
- */
-int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start)
-{
- /* Get the current CPU MID */
- uint64_t current_mid;
-
- asm volatile (
- "ldxa [%1] %2, %0\n"
- : "=r" (current_mid)
- : "r" (0), "i" (ASI_ICBUS_CONFIG)
- );
-
- current_mid >>= ICBUS_CONFIG_MID_SHIFT;
- current_mid &= mid_mask;
-
- /* Wake up the CPUs */
-
- phandle cpus_parent = ofw_find_device("/ssm@0,0");
- if ((cpus_parent == 0) || (cpus_parent == -1))
- cpus_parent = ofw_find_device("/");
-
- phandle node = ofw_get_child_node(cpus_parent);
- int cpus = wake_cpus_in_node(node, current_mid, physmem_start);
- while ((node != 0) && (node != -1)) {
- char name[OFW_TREE_PROPERTY_MAX_VALUELEN];
-
- if (ofw_get_property(node, "name", name,
- OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) {
- name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0;
- if (strcmp(name, "cmp") == 0) {
- phandle subnode = ofw_get_child_node(node);
- cpus += wake_cpus_in_node(subnode,
- current_mid, physmem_start);
- }
- }
- node = ofw_get_peer_node(node);
- }
-
- return cpus;
-}
-
-/** Get physical memory starting address.
- *
- * @param start Pointer to variable where the physical memory starting
- * address will be stored.
- *
- * @return Non-zero on succes, zero on failure.
- *
- */
-int ofw_get_physmem_start(uintptr_t *start)
-{
- uint32_t memreg[4];
- if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0)
- return 0;
-
- *start = (((uint64_t) memreg[0]) << 32) | memreg[1];
- return 1;
-}
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/ofwasm.S b/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/ofwasm.S
deleted file mode 100644
index 4956175131..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/boot/sparc64/loader/ofwasm.S
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# Copyright (c) 2006 Martin Decky
-# Copyright (c) 2006 Jakub Jermar
-# 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.
-# - 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 ``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 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.
-#
-
-/*
- * This code is originally in asm.S. This is the only function used from that
- * file, so it has been relocated to this new file ofw.S which is not actually
- * located in the HelenOS code base.
- */
-
-#include <arch/stack.h>
-#include <boot/register.h>
-
-.register %g2, #scratch
-.register %g3, #scratch
-
-.text
-
-.global ofw
-ofw:
- save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
- set ofw_cif, %l0
- ldx [%l0], %l0
-
- rdpr %pstate, %l1
- and %l1, ~PSTATE_AM_BIT, %l2
- wrpr %l2, 0, %pstate
-
- jmpl %l0, %o7
- mov %i0, %o0
-
- clr %g4 ! correction for gcc's ABI change
-
- wrpr %l1, 0, %pstate
-
- ret
- restore %o0, 0, %o0