Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 25a76ab8 in mainline for boot/arch/sparc64/src/ofw.c


Ignore:
Timestamp:
2010-05-08T07:53:23Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
051bc69a
Parents:
6c39a907 (diff), 1317380 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • boot/arch/sparc64/src/ofw.c

    r6c39a907 r25a76ab8  
    3333 */
    3434
    35 #include <ofwarch.h>
    36 #include <ofw.h>
     35#include <arch/arch.h>
     36#include <arch/ofw.h>
     37#include <genarch/ofw.h>
     38#include <typedefs.h>
    3739#include <printf.h>
    38 #include <string.h>
    39 #include <register.h>
    40 #include "main.h"
    41 #include "asm.h"
     40#include <halt.h>
     41#include <putchar.h>
     42#include <str.h>
    4243
    43 void write(const char *str, const int len)
     44void putchar(const wchar_t ch)
    4445{
    45         int i;
     46        if (ch == '\n')
     47                ofw_putchar('\r');
    4648       
    47         for (i = 0; i < len; i++) {
    48                 if (str[i] == '\n')
    49                         ofw_write("\r", 1);
    50                 ofw_write(&str[i], 1);
    51         }
     49        if (ascii_check(ch))
     50                ofw_putchar(ch);
     51        else
     52                ofw_putchar(U_SPECIAL);
    5253}
    5354
    54 int ofw_translate_failed(ofw_arg_t flag)
    55 {
    56         return flag != -1;
    57 }
    58 
    59 /**
    60  * Starts all CPUs represented by following siblings of the given node,
    61  * except for the current CPU.
     55/** Start all CPUs represented by following siblings of the given node.
     56 *
     57 * Except for the current CPU.
    6258 *
    6359 * @param child         The first child of the OFW tree node whose children
     
    7167 *
    7268 */
    73 static int wake_cpus_in_node(phandle child, uint64_t current_mid,
     69static size_t wake_cpus_in_node(phandle child, uint64_t current_mid,
    7470    uintptr_t physmem_start)
    7571{
    76         int cpus;
     72        size_t cpus;
    7773       
    78         for (cpus = 0; (child != 0) && (child != -1);
     74        for (cpus = 0; (child != 0) && (child != (phandle) -1);
    7975            child = ofw_get_peer_node(child), cpus++) {
    8076                char type_name[OFW_TREE_PROPERTY_MAX_VALUELEN];
     
    8379                    OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) {
    8480                        type_name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0;
    85                         if (strcmp(type_name, "cpu") == 0) {
     81                       
     82                        if (str_cmp(type_name, "cpu") == 0) {
    8683                                uint32_t mid;
    8784                               
     
    10097                                         */
    10198                                        (void) ofw_call("SUNW,start-cpu", 3, 1,
    102                                             NULL, child, KERNEL_VIRTUAL_ADDRESS,
     99                                            NULL, child, KERNEL_ADDRESS,
    103100                                            physmem_start | AP_PROCESSOR);
    104101                                }
     
    110107}
    111108
    112 /**
    113  * Finds out the current CPU's MID and wakes up all AP processors.
     109/** Find out the current CPU's MID and wake up all AP processors.
     110 *
    114111 */
    115 int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start)
     112void ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start)
    116113{
    117114        /* Get the current CPU MID */
     
    119116       
    120117        asm volatile (
    121                 "ldxa [%1] %2, %0\n"
    122                 : "=r" (current_mid)
    123                 : "r" (0), "i" (ASI_ICBUS_CONFIG)
     118                "ldxa [%[zero]] %[asi], %[current_mid]\n"
     119                : [current_mid] "=r" (current_mid)
     120                : [zero] "r" (0),
     121                  [asi] "i" (ASI_ICBUS_CONFIG)
    124122        );
    125123       
     
    130128       
    131129        phandle cpus_parent = ofw_find_device("/ssm@0,0");
    132         if ((cpus_parent == 0) || (cpus_parent == -1))
     130        if ((cpus_parent == 0) || (cpus_parent == (phandle) -1))
    133131                cpus_parent = ofw_find_device("/");
    134132       
    135133        phandle node = ofw_get_child_node(cpus_parent);
    136         int cpus = wake_cpus_in_node(node, current_mid, physmem_start);
    137         while ((node != 0) && (node != -1)) {
     134        size_t cpus = wake_cpus_in_node(node, current_mid, physmem_start);
     135       
     136        while ((node != 0) && (node != (phandle) -1)) {
    138137                char name[OFW_TREE_PROPERTY_MAX_VALUELEN];
    139138               
     
    141140                    OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) {
    142141                        name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0;
    143                         if (strcmp(name, "cmp") == 0) {
     142                       
     143                        if (str_cmp(name, "cmp") == 0) {
    144144                                phandle subnode = ofw_get_child_node(node);
    145145                                cpus += wake_cpus_in_node(subnode,
    146                                         current_mid, physmem_start);
     146                                    current_mid, physmem_start);
    147147                        }
    148148                }
     149               
    149150                node = ofw_get_peer_node(node);
    150151        }
    151152       
    152         return cpus;
     153        if (cpus == 0)
     154                printf("Warning: Unable to get CPU properties.\n");
    153155}
    154156
    155157/** Get physical memory starting address.
    156158 *
    157  * @param start Pointer to variable where the physical memory starting
    158  *              address will be stored.
    159  *
    160  * @return Non-zero on succes, zero on failure.
     159 * @return Physical memory starting address.
    161160 *
    162161 */
    163 int ofw_get_physmem_start(uintptr_t *start)
     162uintptr_t ofw_get_physmem_start(void)
    164163{
    165164        uint32_t memreg[4];
    166         if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0)
    167                 return 0;
     165        if ((ofw_ret_t) ofw_get_property(ofw_memory, "reg", &memreg,
     166            sizeof(memreg)) <= 0) {
     167                printf("Error: Unable to get physical memory starting address, halting.\n");
     168                halt();
     169        }
    168170       
    169         *start = (((uint64_t) memreg[0]) << 32) | memreg[1];
    170         return 1;
     171        return ((((uintptr_t) memreg[0]) << 32) | memreg[1]);
    171172}
Note: See TracChangeset for help on using the changeset viewer.