Changeset 28ecadb in mainline for boot


Ignore:
Timestamp:
2006-09-22T21:44:54Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5d684e4
Parents:
16529d5
Message:

Convert sparc64 to detect keyboard and determine
its physical address by walking the memory representation
of the OpenFirmware device tree.

Add bus-specific functions that know how to apply the
"ranges" property to one component of the "reg" property.
Buses supported so far include FHC, EBUS and PCI.

Location:
boot
Files:
6 edited

Legend:

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

    r16529d5 r28ecadb  
    6666        bootinfo.screen.scanline = bootinfo.screen.scanline*bpp2align[bootinfo.screen.bpp >> 3];
    6767       
    68         if (!ofw_keyboard(&bootinfo.keyboard))
    69                 printf("Error: unable to get keyboard properties\n");
    70 
    7168        if (!ofw_cpu(&bootinfo.cpu))
    7269                printf("Error: unable to get cpu properties\n");
     
    7673        printf(" memory: %dM\n", bootinfo.memmap.total>>20);
    7774        printf(" screen at %P, resolution %dx%d, %d bpp (scanline %d bytes)\n", (uintptr_t) bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
    78         printf(" keyboard at %P (size %d bytes)\n", (uintptr_t) bootinfo.keyboard.addr, bootinfo.keyboard.size);
    7975
    8076        printf("\nMemory statistics\n");
  • boot/arch/sparc64/loader/main.h

    r16529d5 r28ecadb  
    5555        memmap_t memmap;
    5656        screen_t screen;
    57         keyboard_t keyboard;
    5857        cpu_t cpu;
    5958        ballocs_t ballocs;
  • boot/arch/sparc64/loader/ofwarch.c

    r16529d5 r28ecadb  
    9696        for (; node != 0 && node != -1; node = ofw_get_peer_node(node)) {
    9797                if (ofw_get_property(node, "device_type", type_name, sizeof(type_name)) > 0) {
    98                         if (strncmp(type_name, "cpu", 3) == 0) {
     98                        if (strcmp(type_name, "cpu") == 0) {
    9999                                uint32_t mhz;
    100100                               
  • boot/genarch/ofw_tree.c

    r16529d5 r28ecadb  
    4848static void * ofw_tree_space_alloc(size_t size)
    4949{
    50         return balloc(size, size);
     50        char *addr;
     51
     52        /*
     53         * What we do here is a nasty hack :-)
     54         * Problem: string property values that are allocated via this
     55         * function typically do not contain the trailing '\0'. This
     56         * is very uncomfortable for kernel, which is supposed to deal
     57         * with the properties.
     58         * Solution: when allocating space via this function, we always
     59         * allocate space for the extra '\0' character that we store
     60         * behind the requested memory.
     61         */
     62        addr = balloc(size + 1, size);
     63        if (addr)
     64                addr[size] = '\0';
     65        return addr;
    5166}
    5267
     
    154169                        break;
    155170               
    156                 strncpy(current_node->property[i].name, name, sizeof(name));
     171                memcpy(current_node->property[i].name, name, OFW_TREE_PROPERTY_MAX_NAMELEN);
     172                current_node->property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0';
    157173
    158174                size = ofw_get_proplen(current, name);
  • boot/generic/string.c

    r16529d5 r28ecadb  
    5858 * Do a char-by-char comparison of two NULL terminated strings.
    5959 * The strings are considered equal iff they consist of the same
     60 * characters on the minimum of their lengths.
     61 *
     62 * @param src First string to compare.
     63 * @param dst Second string to compare.
     64 *
     65 * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
     66 *
     67 */
     68int strcmp(const char *src, const char *dst)
     69{
     70        for (; *src && *dst; src++, dst++) {
     71                if (*src < *dst)
     72                        return -1;
     73                if (*src > *dst)
     74                        return 1;
     75        }
     76        if (*src == *dst)
     77                return 0;
     78        if (!*src)
     79                return -1;
     80        return 1;
     81}
     82
     83
     84/** Compare two NULL terminated strings
     85 *
     86 * Do a char-by-char comparison of two NULL terminated strings.
     87 * The strings are considered equal iff they consist of the same
    6088 * characters on the minimum of their lengths and specified maximal
    6189 * length.
     
    72100        int i;
    73101       
    74         i = 0;
    75         for (;*src && *dst && i < len;src++,dst++,i++) {
     102        for (i = 0; *src && *dst && i < len; src++, dst++, i++) {
    76103                if (*src < *dst)
    77104                        return -1;
  • boot/generic/string.h

    r16529d5 r28ecadb  
    3939
    4040extern size_t strlen(const char *str);
     41extern int strcmp(const char *src, const char *dst);
    4142extern int strncmp(const char *src, const char *dst, size_t len);
    4243extern void strncpy(char *dest, const char *src, size_t len);
Note: See TracChangeset for help on using the changeset viewer.