Changeset 1787e527 in mainline for boot/arch/sparc64/loader/ofwarch.c


Ignore:
Timestamp:
2009-11-16T21:22:54Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5ebdf94
Parents:
fcbd1be (diff), 9c70ed6 (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:

merged with head (unstable)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/sparc64/loader/ofwarch.c

    rfcbd1be r1787e527  
    3030/**
    3131 * @file
    32  * @brief       Architecture dependent parts of OpenFirmware interface.
     32 * @brief Architecture dependent parts of OpenFirmware interface.
    3333 */
    3434
     
    4040#include "main.h"
    4141#include "asm.h"
    42 
    43 /* these tho variables will be set by the detect_subarchitecture function */
    44 extern uint8_t subarchitecture;
    45 extern uint16_t mid_mask;
    4642
    4743void write(const char *str, const int len)
     
    6561 * except for the current CPU.
    6662 *
    67  * @param child         The first child of the OFW tree node whose children
    68  *                      represent CPUs to be woken up.
    69  * @param current_mid   MID of the current CPU, the current CPU will
    70  *                      (of course) not be woken up.
    71  * @return              Number of CPUs which have the same parent node as
    72  *                      "child".
     63 * @param child         The first child of the OFW tree node whose children
     64 *                      represent CPUs to be woken up.
     65 * @param current_mid   MID of the current CPU, the current CPU will
     66 *                      (of course) not be woken up.
     67 * @param physmem_start Starting address of the physical memory.
     68 *
     69 * @return Number of CPUs which have the same parent node as
     70 *         "child".
     71 *
    7372 */
    74 static int wake_cpus_in_node(phandle child, uint64_t current_mid)
     73static int wake_cpus_in_node(phandle child, uint64_t current_mid,
     74    uintptr_t physmem_start)
    7575{
    7676        int cpus;
    77         char type_name[BUF_SIZE];
    7877       
    79         for (cpus = 0; child != 0 && child != -1;
     78        for (cpus = 0; (child != 0) && (child != -1);
    8079            child = ofw_get_peer_node(child), cpus++) {
     80                char type_name[OFW_TREE_PROPERTY_MAX_VALUELEN];
     81               
    8182                if (ofw_get_property(child, "device_type", type_name,
    82                     sizeof(type_name)) > 0) {
     83                    OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) {
     84                        type_name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0;
    8385                        if (strcmp(type_name, "cpu") == 0) {
    8486                                uint32_t mid;
     
    8890                                 * "cpuid" for US-IV
    8991                                 */
    90                                 if (ofw_get_property(
    91                                     child, "upa-portid",
    92                                     &mid, sizeof(mid)) <= 0
    93                                     && ofw_get_property(child, "portid",
    94                                     &mid, sizeof(mid)) <= 0
    95                                     && ofw_get_property(child, "cpuid",
    96                                     &mid, sizeof(mid)) <= 0)
     92                                if ((ofw_get_property(child, "upa-portid", &mid, sizeof(mid)) <= 0)
     93                                    && (ofw_get_property(child, "portid", &mid, sizeof(mid)) <= 0)
     94                                    && (ofw_get_property(child, "cpuid", &mid, sizeof(mid)) <= 0))
    9795                                        continue;
    98                                        
     96                               
    9997                                if (current_mid != mid) {
    10098                                        /*
     
    103101                                        (void) ofw_call("SUNW,start-cpu", 3, 1,
    104102                                            NULL, child, KERNEL_VIRTUAL_ADDRESS,
    105                                             bootinfo.physmem_start |
    106                                             AP_PROCESSOR);
     103                                            physmem_start | AP_PROCESSOR);
    107104                                }
    108105                        }
    109106                }
    110107        }
    111 
     108       
    112109        return cpus;
    113110}
     
    116113 * Finds out the current CPU's MID and wakes up all AP processors.
    117114 */
    118 int ofw_cpu(void)
     115int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start)
    119116{
    120         int cpus;
    121         phandle node;
    122         phandle subnode;
    123         phandle cpus_parent;
    124         phandle cmp;
    125         char name[BUF_SIZE];
    126 
    127         /* get the current CPU MID */
     117        /* Get the current CPU MID */
    128118        uint64_t current_mid;
    129119       
    130         asm volatile ("ldxa [%1] %2, %0\n"
    131             : "=r" (current_mid)
    132             : "r" (0), "i" (ASI_ICBUS_CONFIG));
     120        asm volatile (
     121                "ldxa [%1] %2, %0\n"
     122                : "=r" (current_mid)
     123                : "r" (0), "i" (ASI_ICBUS_CONFIG)
     124        );
     125       
    133126        current_mid >>= ICBUS_CONFIG_MID_SHIFT;
    134 
    135127        current_mid &= mid_mask;
    136 
    137         /* wake up CPUs */
    138128       
    139         cpus_parent = ofw_find_device("/ssm@0,0");
    140         if (cpus_parent == 0 || cpus_parent == -1) {
     129        /* Wake up the CPUs */
     130       
     131        phandle cpus_parent = ofw_find_device("/ssm@0,0");
     132        if ((cpus_parent == 0) || (cpus_parent == -1))
    141133                cpus_parent = ofw_find_device("/");
    142         }
    143 
    144         node = ofw_get_child_node(cpus_parent);
    145         cpus = wake_cpus_in_node(node, current_mid);
    146         while (node != 0 && node != -1) {
     134       
     135        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)) {
     138                char name[OFW_TREE_PROPERTY_MAX_VALUELEN];
     139               
    147140                if (ofw_get_property(node, "name", name,
    148                         sizeof(name)) > 0) {
     141                    OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) {
     142                        name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0;
    149143                        if (strcmp(name, "cmp") == 0) {
    150                                 subnode = ofw_get_child_node(node);
     144                                phandle subnode = ofw_get_child_node(node);
    151145                                cpus += wake_cpus_in_node(subnode,
    152                                         current_mid);
     146                                        current_mid, physmem_start);
    153147                        }
    154148                }
     
    157151       
    158152        return cpus;
    159        
    160153}
    161154
    162155/** Get physical memory starting address.
    163156 *
    164  * @param start         Pointer to variable where the physical memory starting
    165  *                      address will be stored.
     157 * @param start Pointer to variable where the physical memory starting
     158 *              address will be stored.
    166159 *
    167  * @return              Non-zero on succes, zero on failure.
     160 * @return Non-zero on succes, zero on failure.
     161 *
    168162 */
    169163int ofw_get_physmem_start(uintptr_t *start)
    170164{
    171165        uint32_t memreg[4];
    172 
    173166        if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0)
    174167                return 0;
    175 
     168       
    176169        *start = (((uint64_t) memreg[0]) << 32) | memreg[1];
    177170        return 1;
    178171}
    179 
Note: See TracChangeset for help on using the changeset viewer.