summaryrefslogtreecommitdiffstats
path: root/c
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
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')
-rw-r--r--c/src/lib/libbsp/sparc64/niagara/Makefile.am14
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/LICENSE10
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/README49
-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
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/kernel/sparc64/src/cache.S49
-rw-r--r--c/src/lib/libbsp/sparc64/shared/helenos/kernel/sparc64/src/sun4u/takemmu.S505
-rw-r--r--c/src/lib/libbsp/sparc64/usiii/Makefile.am18
13 files changed, 16 insertions, 2316 deletions
diff --git a/c/src/lib/libbsp/sparc64/niagara/Makefile.am b/c/src/lib/libbsp/sparc64/niagara/Makefile.am
index 23193dc6f7..6a39088dde 100644
--- a/c/src/lib/libbsp/sparc64/niagara/Makefile.am
+++ b/c/src/lib/libbsp/sparc64/niagara/Makefile.am
@@ -25,13 +25,13 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspgetworkarea-defa
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspstart-empty.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspreset-empty.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/start/setvec.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/genarch/balloc.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/genarch/ofw.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/genarch/ofw_tree.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/generic/string.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/sparc64/loader/ofwarch.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/sparc64/loader/main.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/sparc64/loader/ofwasm.S
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/genarch/balloc.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/genarch/ofw.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/genarch/ofw_tree.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/generic/string.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/sparc64/loader/ofwarch.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/sparc64/loader/main.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/sparc64/loader/ofwasm.S
librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/niagara/start/bspinit.S
librtemsbsp_a_SOURCES += ../shared/asm/asm.S
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/LICENSE b/c/src/lib/libbsp/sparc64/shared/helenos/LICENSE
deleted file mode 100644
index 4d0e4db9a9..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/LICENSE
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright (C) 2001-2009 HelenOS project
-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.
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/README b/c/src/lib/libbsp/sparc64/shared/helenos/README
deleted file mode 100644
index 0750429f96..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/README
+++ /dev/null
@@ -1,49 +0,0 @@
-The sources in this directory are from the HelenOS project.
-See: http://www.helenos.org
-
-These sources are from release 0.4.2
-See: http://www.helenos.org/releases/HelenOS-0.4.2.tar.bz2
-
-Unless otherwise indicated, these files are licensed under a BSD-like
-license without advertising clause.
-See: http://www.helenos.org/license
-Or the file LICENSE in this directory.
-
-Source modifications are mostly documented in the individual source code files.
-Source that is removed is discarded by #ifdef 0 ... #endif blocks.
-
-The subdirectories here correspond to the following subdirectories in the
-HelenOS source tree (as of release 0.4.2):
-
-boot
-HelenOS-0.4.2/boot
-Various subdirectories related to booting the sparc64
-
-boot/genarch
-HelenOS-0.4.2/boot/genarch
-
-boot/generic
-HelenOS-0.4.2/boot/generic
-
-boot/include
-Various .h files from the following directories:
- HelenOS-0.4.2/boot/genarch
- HelenOS-0.4.2/boot/generic
- HelenOS-0.4.2/boot/arch/sparc64/loader
-
-boot/sparc64
-HelenOS-0.4.2/boot/arch/sparc64
-
-kernel
-HelenOS-0.4.2/kernel
-Various subdirectories related to kernel code and services for the sparc64
-
-kernel/genarch
-HelenOS-0.4.2/kernel/genarch
-
-kernel/generic
-HelenOS-0.4.2/kernel/generic
-
-kernel/sparc64
-HelenOS-0.4.2/kernel/arch/sparc64/
-
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
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/kernel/sparc64/src/cache.S b/c/src/lib/libbsp/sparc64/shared/helenos/kernel/sparc64/src/cache.S
deleted file mode 100644
index 0aff799c50..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/kernel/sparc64/src/cache.S
+++ /dev/null
@@ -1,49 +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.
- */
-#include <rtems/asm.h>
-#include <arch/arch.h>
-#include <arch/mm/cache_spec.h>
-
-#define DCACHE_TAG_SHIFT 2
-
-.register %g2, #scratch
-.register %g3, #scratch
-
-/** Flush the whole D-cache. */
-.global dcache_flush
-dcache_flush:
- set (DCACHE_SIZE - DCACHE_LINE_SIZE), %g1
- stxa %g0, [%g1] ASI_DCACHE_TAG
-0: membar #Sync
- subcc %g1, DCACHE_LINE_SIZE, %g1
- bnz,pt %xcc, 0b
- stxa %g0, [%g1] ASI_DCACHE_TAG
- membar #Sync
- retl
- ! beware SF Erratum #51, do not put the MEMBAR here
- nop
diff --git a/c/src/lib/libbsp/sparc64/shared/helenos/kernel/sparc64/src/sun4u/takemmu.S b/c/src/lib/libbsp/sparc64/shared/helenos/kernel/sparc64/src/sun4u/takemmu.S
deleted file mode 100644
index f8fa1c6a24..0000000000
--- a/c/src/lib/libbsp/sparc64/shared/helenos/kernel/sparc64/src/sun4u/takemmu.S
+++ /dev/null
@@ -1,505 +0,0 @@
-#
-# Copyright (c) 2005 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 file originally is sparc64/src/sun4u/start.S
- * A lot of changes are made to the code, because we only need the relevant
- * portions for taking over the D- and I-MMUs.
- *
- */
-#define RTEMS
-
-#include <rtems/asm.h>
-
-/* RTEMS: moved all of these to a common include directory */
-#if 0
-#include <arch/arch.h>
-#include <arch/cpu.h>
-#include <arch/regdef.h>
-#endif
-#include <arch/boot.h>
-#include <arch/stack.h>
-
-#include <arch/mm/mmu.h>
-#include <arch/mm/tlb.h>
-#include <arch/mm/tte.h>
-
-#if 0
-#ifdef CONFIG_SMP
-#include <arch/context_offset.h>
-#endif
-#endif
-
-.register %g2, #scratch
-.register %g3, #scratch
-#if defined (RTEMS)
-.section BOOTSTRAP
-#endif
-
-#if 0
-.section K_TEXT_START, "ax"
-
-#define BSP_FLAG 1
-
-/*
- * 2^PHYSMEM_ADDR_SIZE is the size of the physical address space on
- * a given processor.
- */
-#if defined (US)
- #define PHYSMEM_ADDR_SIZE 41
-#elif defined (US3)
- #define PHYSMEM_ADDR_SIZE 43
-#endif
-#endif
-
-#if defined (RTEMS)
- #define PHYSMEM_ADDR_SIZE 43
-#endif
-
-#if 0
-/*
- * Here is where the kernel is passed control from the boot loader.
- *
- * The registers are expected to be in this state:
- * - %o0 starting address of physical memory + bootstrap processor flag
- * bits 63...1: physical memory starting address / 2
- * bit 0: non-zero on BSP processor, zero on AP processors
- * - %o1 bootinfo structure address (BSP only)
- * - %o2 bootinfo structure size (BSP only)
- *
- * Moreover, we depend on boot having established the following environment:
- * - TLBs are on
- * - identity mapping for the kernel image
- */
-.global kernel_image_start
-kernel_image_start:
- mov BSP_FLAG, %l0
- and %o0, %l0, %l7 ! l7 <= bootstrap processor?
- andn %o0, %l0, %l6 ! l6 <= start of physical memory
-
- ! Get bits (PHYSMEM_ADDR_SIZE - 1):13 of physmem_base.
- srlx %l6, 13, %l5
-
- ! l5 <= physmem_base[(PHYSMEM_ADDR_SIZE - 1):13]
- sllx %l5, 13 + (63 - (PHYSMEM_ADDR_SIZE - 1)), %l5
- srlx %l5, 63 - (PHYSMEM_ADDR_SIZE - 1), %l5
-
- /*
- * Setup basic runtime environment.
- */
-
- wrpr %g0, NWINDOWS - 2, %cansave ! set maximum saveable windows
- wrpr %g0, 0, %canrestore ! get rid of windows we will
- ! never need again
- wrpr %g0, 0, %otherwin ! make sure the window state is
- ! consistent
- wrpr %g0, NWINDOWS - 1, %cleanwin ! prevent needless clean_window
- ! traps for kernel
-
- wrpr %g0, 0, %wstate ! use default spill/fill trap
-
- wrpr %g0, 0, %tl ! TL = 0, primary context
- ! register is used
-
- wrpr %g0, PSTATE_PRIV_BIT, %pstate ! disable interrupts and disable
- ! 32-bit address masking
-
- wrpr %g0, 0, %pil ! intialize %pil
-#endif
-
-#if defined (RTEMS)
- /* pass o0 as start of physical memory */
-.global _take_mmu
-_take_mmu:
- save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
- mov %i0, %l6
-#endif
-
- /* these are copied from above */
- ! Get bits (PHYSMEM_ADDR_SIZE - 1):13 of physmem_base.
- srlx %l6, 13, %l5
-
- ! l5 <= physmem_base[(PHYSMEM_ADDR_SIZE - 1):13]
- sllx %l5, 13 + (63 - (PHYSMEM_ADDR_SIZE - 1)), %l5
- srlx %l5, 63 - (PHYSMEM_ADDR_SIZE - 1), %l5
-
- /*
- * Switch to kernel trap table.
- */
- sethi %hi(trap_table), %g1
- wrpr %g1, %lo(trap_table), %tba
-
-
- /*
- * Take over the DMMU by installing locked TTE entry identically
- * mapping the first 4M of memory.
- *
- * In case of DMMU, no FLUSH instructions need to be issued. Because of
- * that, the old DTLB contents can be demapped pretty straightforwardly
- * and without causing any traps.
- */
-
- wr %g0, ASI_DMMU, %asi
-/*
-#define SET_TLB_DEMAP_CMD(r1, context_id) \
- set (TLB_DEMAP_CONTEXT << TLB_DEMAP_TYPE_SHIFT) | (context_id << \
- TLB_DEMAP_CONTEXT_SHIFT), %r1
-*/
-/*
- ! demap context 0
- SET_TLB_DEMAP_CMD(g1, TLB_DEMAP_NUCLEUS)
- stxa %g0, [%g1] ASI_DMMU_DEMAP
- membar #Sync
-*/
-#define SET_TLB_TAG(xVMA, r1, context) \
- set xVMA | (context << TLB_TAG_ACCESS_CONTEXT_SHIFT), %r1
-
- ! write DTLB tag
- SET_TLB_TAG(0x4000, g1, MEM_CONTEXT_KERNEL)
- stxa %g1, [VA_DMMU_TAG_ACCESS] %asi
- membar #Sync
-
-#ifdef CONFIG_VIRT_IDX_DCACHE
-#define TTE_LOW_DATA(imm) (TTE_CP | TTE_CV | TTE_P | LMA | (imm))
-#else /* CONFIG_VIRT_IDX_DCACHE */
-#define TTE_LOW_DATA(imm) (TTE_CP | TTE_P | LMA | (imm))
-#endif /* CONFIG_VIRT_IDX_DCACHE */
-
-#define SET_TLB_DATA(r1, r2, imm) \
- set TTE_LOW_DATA(imm), %r1; \
- or %r1, %l5, %r1; \
- mov PAGESIZE_4M, %r2; \
- sllx %r2, TTE_SIZE_SHIFT, %r2; \
- or %r1, %r2, %r1; \
- mov 1, %r2; \
- sllx %r2, TTE_V_SHIFT, %r2; \
- or %r1, %r2, %r1;
-
- ! write DTLB data and install the kernel mapping
- SET_TLB_DATA(g1, g2, TTE_L | TTE_W) ! use non-global mapping
- stxa %g1, [%g0] ASI_DTLB_DATA_IN_REG
- membar #Sync
-
- /*
- * Because we cannot use global mappings (because we want to have
- * separate 64-bit address spaces for both the kernel and the
- * userspace), we prepare the identity mapping also in context 1. This
- * step is required by the code installing the ITLB mapping.
- */
-/* ! write DTLB tag of context 1 (i.e. MEM_CONTEXT_TEMP)
- SET_TLB_TAG(g1, MEM_CONTEXT_TEMP)
- stxa %g1, [VA_DMMU_TAG_ACCESS] %asi
- membar #Sync
-
- ! write DTLB data and install the kernel mapping in context 1
- SET_TLB_DATA(g1, g2, TTE_W) ! use non-global mapping
- stxa %g1, [%g0] ASI_DTLB_DATA_IN_REG
- membar #Sync
-*/
- /*
- * Now is time to take over the IMMU. Unfortunatelly, it cannot be done
- * as easily as the DMMU, because the IMMU is mapping the code it
- * executes.
- *
- * [ Note that brave experiments with disabling the IMMU and using the
- * DMMU approach failed after a dozen of desparate days with only little
- * success. ]
- *
- * The approach used here is inspired from OpenBSD. First, the kernel
- * creates IMMU mapping for itself in context 1 (MEM_CONTEXT_TEMP) and
- * switches to it. Context 0 (MEM_CONTEXT_KERNEL) can be demapped
- * afterwards and replaced with the kernel permanent mapping. Finally,
- * the kernel switches back to context 0 and demaps context 1.
- *
- * Moreover, the IMMU requires use of the FLUSH instructions. But that
- * is OK because we always use operands with addresses already mapped by
- * the taken over DTLB.
- */
-#if 0
- set kernel_image_start, %g5
-#endif
-#if defined (RTEMS)
- set _take_mmu, %g5
-#endif
-/*
- ! write ITLB tag of context 1
- SET_TLB_TAG(g1, MEM_CONTEXT_TEMP)
- mov VA_DMMU_TAG_ACCESS, %g2
- stxa %g1, [%g2] ASI_IMMU
- flush %g5
-
- ! write ITLB data and install the temporary mapping in context 1
- SET_TLB_DATA(g1, g2, 0) ! use non-global mapping
- stxa %g1, [%g0] ASI_ITLB_DATA_IN_REG
- flush %g5
-
- ! switch to context 1
- mov MEM_CONTEXT_TEMP, %g1
- stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi ! ASI_DMMU is correct here !!!
- flush %g5
-
- ! demap context 0
- SET_TLB_DEMAP_CMD(g1, TLB_DEMAP_NUCLEUS)
- stxa %g0, [%g1] ASI_IMMU_DEMAP
- flush %g5
-*/
- ! write ITLB tag of context 0
- SET_TLB_TAG(0x4000, g1, MEM_CONTEXT_KERNEL)
- mov VA_DMMU_TAG_ACCESS, %g2
- stxa %g1, [%g2] ASI_IMMU
- flush %g5
-
- ! write ITLB data and install the permanent kernel mapping in context 0
- SET_TLB_DATA(g1, g2, TTE_L) ! use non-global mapping
- stxa %g1, [%g0] ASI_ITLB_DATA_IN_REG
- flush %g5
-
- ! GAB: add more mappings for dmmu in 4 MB chunks
- SET_TLB_TAG(0x404000, g1, MEM_CONTEXT_KERNEL)
- stxa %g1, [VA_DMMU_TAG_ACCESS] %asi
- membar #Sync
- set 0x400000, %g1
- add %g1, %l5, %l5
- SET_TLB_DATA(g1, g2, TTE_L | TTE_W)
- stxa %g1, [%g0] ASI_DTLB_DATA_IN_REG
- membar #Sync
-
- SET_TLB_TAG(0x804000, g1, MEM_CONTEXT_KERNEL)
- stxa %g1, [VA_DMMU_TAG_ACCESS] %asi
- membar #Sync
- set 0x400000, %g1
- add %g1, %l5, %l5
- SET_TLB_DATA(g1, g2, TTE_L | TTE_W)
- stxa %g1, [%g0] ASI_DTLB_DATA_IN_REG
- membar #Sync
-
- SET_TLB_TAG(0xc04000, g1, MEM_CONTEXT_KERNEL)
- stxa %g1, [VA_DMMU_TAG_ACCESS] %asi
- membar #Sync
- set 0x400000, %g1
- add %g1, %l5, %l5
- SET_TLB_DATA(g1, g2, TTE_L | TTE_W)
- stxa %g1, [%g0] ASI_DTLB_DATA_IN_REG
- membar #Sync
-
-
-/*
- ! enter nucleus - using context 0
- wrpr %g0, 1, %tl
-
- ! demap context 1
- SET_TLB_DEMAP_CMD(g1, TLB_DEMAP_PRIMARY)
- stxa %g0, [%g1] ASI_IMMU_DEMAP
- flush %g5
-
- ! set context 0 in the primary context register
- stxa %g0, [VA_PRIMARY_CONTEXT_REG] %asi ! ASI_DMMU is correct here !!!
- flush %g5
-
- ! leave nucleus - using primary context, i.e. context 0
- wrpr %g0, 0, %tl
-
- wrpr %g0, 0, %wstate ! default spill/fill trap
-*/
-#if 0
- brz %l7, 1f ! skip if you are not the bootstrap CPU
- nop
-
- /*
- * Save physmem_base for use by the mm subsystem.
- * %l6 contains starting physical address
- */
- sethi %hi(physmem_base), %l4
- stx %l6, [%l4 + %lo(physmem_base)]
-
- /*
- * Precompute kernel 8K TLB data template.
- * %l5 contains starting physical address
- * bits [(PHYSMEM_ADDR_SIZE - 1):13]
- */
- sethi %hi(kernel_8k_tlb_data_template), %l4
- ldx [%l4 + %lo(kernel_8k_tlb_data_template)], %l3
- or %l3, %l5, %l3
- stx %l3, [%l4 + %lo(kernel_8k_tlb_data_template)]
-#endif
-
- /*
- * Flush D-Cache.
- */
- call dcache_flush
- nop
-
-#if 0
- /*
- * So far, we have not touched the stack.
- * It is a good idea to set the kernel stack to a known state now.
- */
- sethi %hi(temporary_boot_stack), %sp
- or %sp, %lo(temporary_boot_stack), %sp
- sub %sp, STACK_BIAS, %sp
-
- sethi %hi(bootinfo), %o0
- call memcpy ! copy bootinfo
- or %o0, %lo(bootinfo), %o0
-
- call arch_pre_main
- nop
-
- call main_bsp
- nop
-#endif
-
-#if defined (RTEMS)
- ret
- restore
-#endif
-
- /* Not reached. */
-
-0:
- ba %xcc, 0b
- nop
-
-#if 0
-1:
-#ifdef CONFIG_SMP
- /*
- * Determine the width of the MID and save its mask to %g3. The width
- * is
- * * 5 for US and US-IIIi,
- * * 10 for US3 except US-IIIi.
- */
-#if defined(US)
- mov 0x1f, %g3
-#elif defined(US3)
- mov 0x3ff, %g3
- rdpr %ver, %g2
- sllx %g2, 16, %g2
- srlx %g2, 48, %g2
- cmp %g2, IMPL_ULTRASPARCIII_I
- move %xcc, 0x1f, %g3
-#endif
-
- /*
- * Read MID from the processor.
- */
- ldxa [%g0] ASI_ICBUS_CONFIG, %g1
- srlx %g1, ICBUS_CONFIG_MID_SHIFT, %g1
- and %g1, %g3, %g1
-
- /*
- * Active loop for APs until the BSP picks them up. A processor cannot
- * leave the loop until the global variable 'waking_up_mid' equals its
- * MID.
- */
- set waking_up_mid, %g2
-2:
- ldx [%g2], %g3
- cmp %g3, %g1
- bne %xcc, 2b
- nop
-
- /*
- * Configure stack for the AP.
- * The AP is expected to use the stack saved
- * in the ctx global variable.
- */
- set ctx, %g1
- add %g1, OFFSET_SP, %g1
- ldx [%g1], %o6
-
- call main_ap
- nop
-
- /* Not reached. */
-#endif
-
-0:
- ba %xcc, 0b
- nop
-
-
-.section K_DATA_START, "aw", @progbits
-
-/*
- * Create small stack to be used by the bootstrap processor. It is going to be
- * used only for a very limited period of time, but we switch to it anyway,
- * just to be sure we are properly initialized.
- */
-
-#define INITIAL_STACK_SIZE 1024
-
-.align STACK_ALIGNMENT
- .space INITIAL_STACK_SIZE
-.align STACK_ALIGNMENT
-temporary_boot_stack:
- .space STACK_WINDOW_SAVE_AREA_SIZE
-
-#endif /* 0 */
-
-.data
-
-.align 8
-.global physmem_base ! copy of the physical memory base address
-physmem_base:
- .quad 0
-
-/*
- * The fast_data_access_mmu_miss_data_hi label and the end_of_identity and
- * kernel_8k_tlb_data_template variables are meant to stay together,
- * aligned on 16B boundary.
- */
-.global fast_data_access_mmu_miss_data_hi
-.global end_of_identity
-.global kernel_8k_tlb_data_template
-
-.align 16
-/*
- * This label is used by the fast_data_access_MMU_miss trap handler.
- */
-fast_data_access_mmu_miss_data_hi:
-/*
- * This variable is used by the fast_data_access_MMU_miss trap handler.
- * In runtime, it is modified to contain the address of the end of physical
- * memory.
- */
-end_of_identity:
- .quad -1
-/*
- * This variable is used by the fast_data_access_MMU_miss trap handler.
- * In runtime, it is further modified to reflect the starting address of
- * physical memory.
- */
-kernel_8k_tlb_data_template:
-#ifdef CONFIG_VIRT_IDX_DCACHE
- .quad ((1 << TTE_V_SHIFT) | (PAGESIZE_8K << TTE_SIZE_SHIFT) | TTE_CP | \
- TTE_CV | TTE_P | TTE_W)
-#else /* CONFIG_VIRT_IDX_DCACHE */
- .quad ((1 << TTE_V_SHIFT) | (PAGESIZE_8K << TTE_SIZE_SHIFT) | TTE_CP | \
- TTE_P | TTE_W)
-#endif /* CONFIG_VIRT_IDX_DCACHE */
diff --git a/c/src/lib/libbsp/sparc64/usiii/Makefile.am b/c/src/lib/libbsp/sparc64/usiii/Makefile.am
index 1ddd825b29..0b3eeeba5d 100644
--- a/c/src/lib/libbsp/sparc64/usiii/Makefile.am
+++ b/c/src/lib/libbsp/sparc64/usiii/Makefile.am
@@ -32,18 +32,18 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/getentropy/getentropy
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspgetworkarea-default.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspreset-empty.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/start/setvec.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/genarch/balloc.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/genarch/ofw.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/genarch/ofw_tree.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/generic/string.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/sparc64/loader/ofwarch.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/sparc64/loader/main.c
-librtemsbsp_a_SOURCES += ../shared/helenos/boot/sparc64/loader/ofwasm.S
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/genarch/balloc.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/genarch/ofw.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/genarch/ofw_tree.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/generic/string.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/sparc64/loader/ofwarch.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/sparc64/loader/main.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/boot/sparc64/loader/ofwasm.S
librtemsbsp_a_SOURCES += ../shared/asm/asm.S
librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/usiii/start/bspinit.S
-librtemsbsp_a_SOURCES += ../shared/helenos/kernel/sparc64/src/cache.S
-librtemsbsp_a_SOURCES += ../shared/helenos/kernel/sparc64/src/sun4u/takemmu.S
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/kernel/sparc64/src/cache.S
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/helenos/kernel/sparc64/src/sun4u/takemmu.S
librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc64/shared/start/trap_table.S
librtemsbsp_a_SOURCES +=../../../../../../bsps/sparc64/shared/clock/ckinit.c