Changeset 28ecadb in mainline
- Timestamp:
- 2006-09-22T21:44:54Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5d684e4
- Parents:
- 16529d5
- Files:
-
- 3 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/sparc64/loader/main.c
r16529d5 r28ecadb 66 66 bootinfo.screen.scanline = bootinfo.screen.scanline*bpp2align[bootinfo.screen.bpp >> 3]; 67 67 68 if (!ofw_keyboard(&bootinfo.keyboard))69 printf("Error: unable to get keyboard properties\n");70 71 68 if (!ofw_cpu(&bootinfo.cpu)) 72 69 printf("Error: unable to get cpu properties\n"); … … 76 73 printf(" memory: %dM\n", bootinfo.memmap.total>>20); 77 74 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);79 75 80 76 printf("\nMemory statistics\n"); -
boot/arch/sparc64/loader/main.h
r16529d5 r28ecadb 55 55 memmap_t memmap; 56 56 screen_t screen; 57 keyboard_t keyboard;58 57 cpu_t cpu; 59 58 ballocs_t ballocs; -
boot/arch/sparc64/loader/ofwarch.c
r16529d5 r28ecadb 96 96 for (; node != 0 && node != -1; node = ofw_get_peer_node(node)) { 97 97 if (ofw_get_property(node, "device_type", type_name, sizeof(type_name)) > 0) { 98 if (str ncmp(type_name, "cpu", 3) == 0) {98 if (strcmp(type_name, "cpu") == 0) { 99 99 uint32_t mhz; 100 100 -
boot/genarch/ofw_tree.c
r16529d5 r28ecadb 48 48 static void * ofw_tree_space_alloc(size_t size) 49 49 { 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; 51 66 } 52 67 … … 154 169 break; 155 170 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'; 157 173 158 174 size = ofw_get_proplen(current, name); -
boot/generic/string.c
r16529d5 r28ecadb 58 58 * Do a char-by-char comparison of two NULL terminated strings. 59 59 * 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 */ 68 int 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 60 88 * characters on the minimum of their lengths and specified maximal 61 89 * length. … … 72 100 int i; 73 101 74 i = 0; 75 for (;*src && *dst && i < len;src++,dst++,i++) { 102 for (i = 0; *src && *dst && i < len; src++, dst++, i++) { 76 103 if (*src < *dst) 77 104 return -1; -
boot/generic/string.h
r16529d5 r28ecadb 39 39 40 40 extern size_t strlen(const char *str); 41 extern int strcmp(const char *src, const char *dst); 41 42 extern int strncmp(const char *src, const char *dst, size_t len); 42 43 extern void strncpy(char *dest, const char *src, size_t len); -
kernel/Makefile
r16529d5 r28ecadb 82 82 ifeq ($(CONFIG_TSB),y) 83 83 DEFS += -DCONFIG_TSB 84 endif 85 86 ifeq ($(CONFIG_Z8530),y) 87 DEFS += -DCONFIG_Z8530 88 endif 89 90 ifeq ($(CONFIG_NS16550),y) 91 DEFS += -DCONFIG_NS16550 84 92 endif 85 93 -
kernel/arch/sparc64/Makefile.inc
r16529d5 r28ecadb 61 61 CONFIG_FB = y 62 62 63 ## Compile with support for Sun keyboard. 64 # 65 66 CONFIG_SUN_KBD = y 67 63 68 ## Compile with support for OpenFirmware device tree. 64 69 # 65 70 66 71 CONFIG_OFW_TREE = y 67 68 ifeq ($(MACHINE),enterprise)69 ## Compile with support for z8530 controller.70 #71 72 CONFIG_Z8530 = y73 DEFS += -DCONFIG_Z853074 endif75 ifeq ($(MACHINE),ultra)76 ## Compile with support for ns16550 controller.77 #78 79 CONFIG_NS16550 = y80 DEFS += -DCONFIG_NS1655081 82 DEFS += -DKBD_ADDR_OVRD=0x1fff13083f8ULL83 84 endif85 86 72 87 73 ARCH_SOURCES = \ -
kernel/arch/sparc64/include/boot/boot.h
r16529d5 r28ecadb 80 80 81 81 typedef struct { 82 uintptr_t addr;83 uint32_t size;84 } keyboard_t;85 86 typedef struct {87 82 uint32_t clock_frequency; 88 83 } processor_t; … … 96 91 memmap_t memmap; 97 92 screen_t screen; 98 keyboard_t keyboard;99 93 processor_t processor; 100 94 ballocs_t ballocs; -
kernel/arch/sparc64/include/drivers/kbd.h
r16529d5 r28ecadb 37 37 38 38 #include <arch/types.h> 39 #include <genarch/ofw/ofw_tree.h> 40 41 typedef enum { 42 KBD_UNKNOWN, 43 KBD_Z8530, 44 KBD_NS16550 45 } kbd_type_t; 46 47 extern kbd_type_t kbd_type; 39 48 40 49 extern volatile uint8_t *kbd_virt_address; 41 50 42 extern void kbd_init( void);51 extern void kbd_init(ofw_tree_node_t *node); 43 52 44 53 #endif -
kernel/arch/sparc64/src/console.c
r16529d5 r28ecadb 54 54 #include <arch/mm/tlb.h> 55 55 #include <arch/boot/boot.h> 56 #include <genarch/ofw/ofw_tree.h> 56 57 #include <arch.h> 58 #include <panic.h> 59 #include <print.h> 57 60 58 61 #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ … … 62 65 { 63 66 stdin = NULL; 64 67 68 ofw_tree_node_t *aliases; 69 ofw_tree_property_t *prop; 70 ofw_tree_node_t *screen; 71 ofw_tree_node_t *keyboard; 72 73 aliases = ofw_tree_lookup("/aliases"); 74 if (!aliases) 75 panic("Can't find /aliases.\n"); 76 77 prop = ofw_tree_getprop(aliases, "screen"); 78 if (!prop) 79 panic("Can't find property \"screen\".\n"); 80 if (!prop->value) 81 panic("Can't find screen alias.\n"); 82 screen = ofw_tree_lookup(prop->value); 83 if (!screen) 84 panic("Can't find %s\n", prop->value); 85 65 86 fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, 66 87 bootinfo.screen.bpp, bootinfo.screen.scanline, true); 88 89 prop = ofw_tree_getprop(aliases, "keyboard"); 90 if (!prop) 91 panic("Can't find property \"keyboard\".\n"); 92 if (!prop->value) 93 panic("Can't find keyboard alias.\n"); 94 keyboard = ofw_tree_lookup(prop->value); 95 if (!keyboard) 96 panic("Can't find %s\n", prop->value); 67 97 68 #ifdef KBD_ADDR_OVRD 69 if (!bootinfo.keyboard.addr) 70 bootinfo.keyboard.addr = KBD_ADDR_OVRD; 71 #endif 72 73 if (bootinfo.keyboard.addr) 74 kbd_init(); 98 kbd_init(keyboard); 75 99 } 76 100 … … 83 107 thread_detach(THREAD); 84 108 85 if (!bootinfo.keyboard.addr)86 return;87 88 while (1) {89 109 #ifdef CONFIG_Z8530 110 if (kbd_type == KBD_Z8530) 90 111 return; 91 112 #endif 113 114 while (1) { 92 115 #ifdef CONFIG_NS16550 93 ns16550_poll(); 116 if (kbd_type == KBD_NS16550) 117 ns16550_poll(); 94 118 #endif 95 119 thread_usleep(KEYBOARD_POLL_PAUSE); … … 103 127 { 104 128 #ifdef CONFIG_Z8530 105 z8530_grab(); 129 if (kbd_type == KBD_Z8530) 130 z8530_grab(); 106 131 #endif 107 132 } … … 113 138 { 114 139 #ifdef CONFIG_Z8530 115 z8530_release(); 140 if (kbd_type == KBD_Z8530) 141 z8530_release(); 116 142 #endif 117 143 } -
kernel/arch/sparc64/src/drivers/kbd.c
r16529d5 r28ecadb 34 34 35 35 #include <arch/drivers/kbd.h> 36 #include <genarch/ofw/ofw_tree.h> 36 37 #ifdef CONFIG_Z8530 37 38 #include <genarch/kbd/z8530.h> … … 41 42 #endif 42 43 43 #include <arch/boot/boot.h>44 44 #include <arch/mm/page.h> 45 45 #include <arch/types.h> 46 46 #include <typedefs.h> 47 47 #include <align.h> 48 #include <func.h> 49 #include <print.h> 48 50 49 51 volatile uint8_t *kbd_virt_address = NULL; 50 52 51 void kbd_init() 53 kbd_type_t kbd_type = KBD_UNKNOWN; 54 55 /** Initialize keyboard. 56 * 57 * Traverse OpenFirmware device tree in order to find necessary 58 * info about the keyboard device. 59 * 60 * @param node Keyboard device node. 61 */ 62 void kbd_init(ofw_tree_node_t *node) 52 63 { 53 64 size_t offset; 54 65 uintptr_t aligned_addr; 55 56 /* FIXME: supply value read from OpenFirmware */ 57 bootinfo.keyboard.size = 8; 58 66 ofw_tree_property_t *prop; 67 const char *name; 68 69 name = ofw_tree_node_name(node); 70 71 if (strcmp(name, "zs") == 0) 72 kbd_type = KBD_Z8530; 73 else if (strcmp(name, "su") == 0) 74 kbd_type = KBD_NS16550; 75 76 if (kbd_type == KBD_UNKNOWN) { 77 printf("Unknown keyboard device.\n"); 78 return; 79 } 80 81 prop = ofw_tree_getprop(node, "reg"); 82 if (!prop) 83 panic("Can't find \"reg\" property.\n"); 84 85 uintptr_t pa; 86 size_t size; 87 88 switch (kbd_type) { 89 case KBD_Z8530: 90 size = ((ofw_fhc_reg_t *) prop->value)->size; 91 if (!ofw_fhc_apply_ranges(node->parent, ((ofw_fhc_reg_t *) prop->value) , &pa)) { 92 printf("Failed to determine keyboard address.\n"); 93 return; 94 } 95 break; 96 case KBD_NS16550: 97 size = ((ofw_ebus_reg_t *) prop->value)->size; 98 if (!ofw_ebus_apply_ranges(node->parent, ((ofw_ebus_reg_t *) prop->value) , &pa)) { 99 printf("Failed to determine keyboard address.\n"); 100 return; 101 } 102 break; 103 default: 104 panic("Unexpected type.\n"); 105 } 106 59 107 /* 60 108 * We need to pass aligned address to hw_map(). 61 109 * However, the physical keyboard address can 62 * be pretty much unaligned on some systems63 * (e.g. Ultra 5, Ultra 60).110 * be pretty much unaligned, depending on the 111 * underlying controller. 64 112 */ 65 aligned_addr = ALIGN_DOWN( bootinfo.keyboard.addr, PAGE_SIZE);66 offset = bootinfo.keyboard.addr- aligned_addr;67 kbd_virt_address = (uint8_t *) hw_map(aligned_addr, offset + bootinfo.keyboard.size) + offset;113 aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); 114 offset = pa - aligned_addr; 115 kbd_virt_address = (uint8_t *) hw_map(aligned_addr, offset + size) + offset; 68 116 117 switch (kbd_type) { 69 118 #ifdef CONFIG_Z8530 70 z8530_init(); 119 case KBD_Z8530: 120 z8530_init(); 121 break; 71 122 #endif 72 123 #ifdef CONFIG_NS16550 73 ns16550_init(); 124 case KBD_NS16550: 125 ns16550_init(); 126 break; 74 127 #endif 128 default: 129 printf("Kernel is not compiled with the necessary keyboard driver this machine requires.\n"); 130 } 75 131 } 76 132 -
kernel/arch/sparc64/src/trap/interrupt.c
r16529d5 r28ecadb 37 37 #include <interrupt.h> 38 38 #include <arch/drivers/fhc.h> 39 #include <arch/drivers/kbd.h> 39 40 #include <typedefs.h> 40 41 #include <arch/types.h> … … 63 64 { 64 65 #ifdef CONFIG_Z8530 65 z8530_belongs_to_kernel = false; 66 if (kbd_type == KBD_Z8530) 67 z8530_belongs_to_kernel = false; 66 68 #endif 67 69 } … … 78 80 #ifdef CONFIG_Z8530 79 81 case Z8530_INTRCV_DATA0: 82 if (kbd_type != KBD_Z8530) 83 break; 80 84 /* 81 85 * So far, we know we got this interrupt through the FHC. -
kernel/genarch/Makefile.inc
r16529d5 r28ecadb 73 73 endif 74 74 75 ## Sun keyboard 76 ifeq ($(CONFIG_SUN_KBD),y) 77 GENARCH_SOURCES += \ 78 genarch/src/kbd/key.c \ 79 genarch/src/kbd/scanc_sun.c 80 endif 81 75 82 ## z8530 controller 76 83 ifeq ($(CONFIG_Z8530),y) 77 84 GENARCH_SOURCES += \ 78 genarch/src/kbd/z8530.c \ 79 genarch/src/kbd/key.c \ 80 genarch/src/kbd/scanc_sun.c 85 genarch/src/kbd/z8530.c 81 86 endif 82 87 … … 84 89 ifeq ($(CONFIG_NS16550),y) 85 90 GENARCH_SOURCES += \ 86 genarch/src/kbd/ns16550.c \ 87 genarch/src/kbd/key.c \ 88 genarch/src/kbd/scanc_sun.c 91 genarch/src/kbd/ns16550.c 89 92 endif 90 93 … … 93 96 ifeq ($(CONFIG_OFW_TREE), y) 94 97 GENARCH_SOURCES += \ 95 genarch/src/ofw/ofw_tree.c 98 genarch/src/ofw/ofw_tree.c \ 99 genarch/src/ofw/ebus.c \ 100 genarch/src/ofw/fhc.c \ 101 genarch/src/ofw/pci.c 96 102 endif -
kernel/genarch/include/kbd/i8042.h
r16529d5 r28ecadb 36 36 #define KERN_I8042_H_ 37 37 38 #include <typedefs.h> 39 38 40 extern void i8042_init(void); 39 41 extern void i8042_poll(void); 40 42 extern void i8042_grab(void); 41 43 extern void i8042_release(void); 44 extern char i8042_key_read(chardev_t *d); 42 45 43 46 #endif -
kernel/genarch/include/kbd/key.h
r16529d5 r28ecadb 50 50 extern void active_read_key_pressed(uint8_t sc); 51 51 52 extern char key_read(chardev_t *d);53 54 52 #endif 55 53 -
kernel/genarch/include/kbd/ns16550.h
r16529d5 r28ecadb 38 38 #define KERN_NS16550_H_ 39 39 40 #include <typedefs.h> 41 40 42 extern void ns16550_init(void); 41 43 extern void ns16550_poll(void); 42 44 extern void ns16550_grab(void); 43 45 extern void ns16550_release(void); 46 extern char ns16550_key_read(chardev_t *d); 44 47 45 48 #endif -
kernel/genarch/include/kbd/z8530.h
r16529d5 r28ecadb 49 49 extern void z8530_release(void); 50 50 extern void z8530_interrupt(void); 51 extern char z8530_key_read(chardev_t *d); 51 52 52 53 #endif -
kernel/genarch/include/ofw/ofw_tree.h
r16529d5 r28ecadb 57 57 }; 58 58 59 /* 60 * Definition of 'reg' and 'ranges' properties for various buses. 61 */ 62 63 struct ofw_fhc_reg { 64 uint64_t addr; 65 uint32_t size; 66 } __attribute__ ((packed)); 67 typedef struct ofw_fhc_reg ofw_fhc_reg_t; 68 69 struct ofw_fhc_range { 70 uint64_t child_base; 71 uint64_t parent_base; 72 uint32_t size; 73 } __attribute__ ((packed)); 74 typedef struct ofw_fhc_range ofw_fhc_range_t; 75 76 struct ofw_central_reg { 77 uint64_t addr; 78 uint32_t size; 79 } __attribute__ ((packed)); 80 typedef struct ofw_central_reg ofw_central_reg_t; 81 82 struct ofw_central_range { 83 uint64_t child_base; 84 uint64_t parent_base; 85 uint32_t size; 86 } __attribute__ ((packed)); 87 typedef struct ofw_central_range ofw_central_range_t; 88 89 struct ofw_ebus_reg { 90 uint32_t space; 91 uint32_t addr; 92 uint32_t size; 93 } __attribute__ ((packed)); 94 typedef struct ofw_ebus_reg ofw_ebus_reg_t; 95 96 struct ofw_ebus_range { 97 uint32_t child_space; 98 uint32_t child_base; 99 uint32_t parent_space; 100 uint64_t parent_base; /* group phys.mid and phys.lo together */ 101 uint32_t size; 102 } __attribute__ ((packed)); 103 typedef struct ofw_ebus_range ofw_ebus_range_t; 104 105 struct ofw_pci_reg { 106 uint32_t space; /* needs to masked to obtain pure space id */ 107 uint64_t addr; /* group phys.mid and phys.lo together */ 108 uint64_t size; 109 } __attribute__ ((packed)); 110 typedef struct ofw_pci_reg ofw_pci_reg_t; 111 112 struct ofw_pci_range { 113 uint32_t space; 114 uint64_t child_base; /* group phys.mid and phys.lo together */ 115 uint64_t parent_base; 116 uint64_t size; 117 } __attribute__ ((packed)); 118 typedef struct ofw_pci_range ofw_pci_range_t; 119 120 struct ofw_ffb_reg { 121 } __attribute__ ((packed)); 122 typedef struct ofw_ffb_reg ofw_ffb_reg_t; 123 59 124 extern void ofw_tree_init(ofw_tree_node_t *root); 60 125 extern void ofw_tree_print(void); 61 126 extern const char *ofw_tree_node_name(const ofw_tree_node_t *node); 62 127 extern ofw_tree_node_t *ofw_tree_lookup(const char *path); 128 extern ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *node, const char *name); 129 130 extern bool ofw_fhc_apply_ranges(ofw_tree_node_t *node, ofw_fhc_reg_t *reg, uintptr_t *pa); 131 extern bool ofw_central_apply_ranges(ofw_tree_node_t *node, ofw_central_reg_t *reg, uintptr_t *pa); 132 extern bool ofw_ebus_apply_ranges(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uintptr_t *pa); 133 extern bool ofw_pci_apply_ranges(ofw_tree_node_t *node, ofw_pci_reg_t *reg, uintptr_t *pa); 134 extern bool ofw_ffb_apply_ranges(ofw_tree_node_t *node, ofw_ffb_reg_t *reg, uintptr_t *pa); 63 135 64 136 #endif -
kernel/genarch/src/kbd/i8042.c
r16529d5 r28ecadb 81 81 static void i8042_resume(chardev_t *); 82 82 83 chardev_t kbrd;84 83 static chardev_operations_t ops = { 85 84 .suspend = i8042_suspend, 86 85 .resume = i8042_resume, 87 .read = key_read86 .read = i8042_key_read 88 87 }; 89 88 … … 174 173 } 175 174 176 char key_read(chardev_t *d)175 char i8042_key_read(chardev_t *d) 177 176 { 178 177 char ch; -
kernel/genarch/src/kbd/key.c
r16529d5 r28ecadb 54 54 #define ACTIVE_READ_BUFF_SIZE 16 /* Must be power of 2 */ 55 55 56 chardev_t kbrd; 57 56 58 static uint8_t active_read_buff[ACTIVE_READ_BUFF_SIZE]; 57 59 -
kernel/genarch/src/kbd/ns16550.c
r16529d5 r28ecadb 60 60 static void ns16550_resume(chardev_t *); 61 61 62 chardev_t kbrd;63 62 static chardev_operations_t ops = { 64 63 .suspend = ns16550_suspend, 65 64 .resume = ns16550_resume, 66 .read = key_read65 .read = ns16550_key_read 67 66 }; 68 67 … … 119 118 } 120 119 121 char key_read(chardev_t *d)120 char ns16550_key_read(chardev_t *d) 122 121 { 123 122 char ch; -
kernel/genarch/src/kbd/z8530.c
r16529d5 r28ecadb 63 63 static void z8530_resume(chardev_t *); 64 64 65 chardev_t kbrd;66 65 static chardev_operations_t ops = { 67 66 .suspend = z8530_suspend, 68 67 .resume = z8530_resume, 69 .read = key_read68 .read = z8530_key_read 70 69 }; 71 70 … … 142 141 } 143 142 144 char key_read(chardev_t *d)143 char z8530_key_read(chardev_t *d) 145 144 { 146 145 char ch; -
kernel/genarch/src/ofw/ofw_tree.c
r16529d5 r28ecadb 52 52 } 53 53 54 /** Get OpenFirmware node property. 55 * 56 * @param node Node in which to lookup the property. 57 * @param name Name of the property. 58 * 59 * @return Pointer to the property structure or NULL if no such property. 60 */ 61 ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *node, const char *name) 62 { 63 int i; 64 65 for (i = 0; i < node->properties; i++) { 66 if (strcmp(node->property[i].name, name) == 0) 67 return &node->property[i]; 68 } 69 70 return NULL; 71 } 72 54 73 /** Return value of the 'name' property. 55 74 * … … 60 79 const char *ofw_tree_node_name(const ofw_tree_node_t *node) 61 80 { 62 int i;81 ofw_tree_property_t *prop; 63 82 64 for (i = 0; i < node->properties; i++) { 65 if (strncmp(node->property[i].name, "name", strlen("name")) == 0) { 66 if (node->property[i].size < 2) 67 panic("Invalid name property.\n"); 68 return node->property[i].value; 69 } 70 } 83 prop = ofw_tree_getprop(node, "name"); 84 if (!prop) 85 panic("Node without name property.\n"); 86 87 if (prop->size < 2) 88 panic("Invalid name property.\n"); 71 89 72 panic("Node without name property.\n");90 return prop->value; 73 91 } 74 92 … … 76 94 * 77 95 * @param node Node whose child is being looked up. 78 * @param da_name Disambigued name of the child being looked up.96 * @param name Name of the child being looked up. 79 97 * 80 98 * @return NULL if there is no such child or pointer to the matching child node. 81 99 */ 82 static ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, const char * da_name)100 static ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, const char *name) 83 101 { 84 102 ofw_tree_node_t *cur; 85 103 104 /* 105 * Try to find the disambigued name. 106 */ 86 107 for (cur = node->child; cur; cur = cur->peer) { 87 if (str ncmp(cur->da_name, da_name, strlen(da_name)) == 0)108 if (strcmp(cur->da_name, name) == 0) 88 109 return cur; 89 110 } 90 111 112 /* 113 * Disambigued name not found. 114 * Lets try our luck with possibly ambiguous "name" property. 115 * 116 * We need to do this because paths stored in "/aliases" 117 * are not always fully-qualified. 118 */ 119 for (cur = node->child; cur; cur = cur->peer) { 120 if (strcmp(ofw_tree_node_name(cur), name) == 0) 121 return cur; 122 } 123 91 124 return NULL; 92 125 } -
kernel/generic/include/func.h
r16529d5 r28ecadb 45 45 46 46 extern size_t strlen(const char *str); 47 extern int strcmp(const char *src, const char *dst); 47 48 extern int strncmp(const char *src, const char *dst, size_t len); 48 49 extern void strncpy(char *dest, const char *src, size_t len); -
kernel/generic/src/lib/func.c
r16529d5 r28ecadb 101 101 * Do a char-by-char comparison of two NULL terminated strings. 102 102 * The strings are considered equal iff they consist of the same 103 * characters on the minimum of their lengths. 104 * 105 * @param src First string to compare. 106 * @param dst Second string to compare. 107 * 108 * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller. 109 * 110 */ 111 int strcmp(const char *src, const char *dst) 112 { 113 for (; *src && *dst; src++, dst++) { 114 if (*src < *dst) 115 return -1; 116 if (*src > *dst) 117 return 1; 118 } 119 if (*src == *dst) 120 return 0; 121 if (!*src) 122 return -1; 123 return 1; 124 } 125 126 127 /** Compare two NULL terminated strings 128 * 129 * Do a char-by-char comparison of two NULL terminated strings. 130 * The strings are considered equal iff they consist of the same 103 131 * characters on the minimum of their lengths and specified maximal 104 132 * length. … … 115 143 int i; 116 144 117 i = 0; 118 for (;*src && *dst && i < len;src++,dst++,i++) { 145 for (i = 0; *src && *dst && i < len; src++, dst++, i++) { 119 146 if (*src < *dst) 120 147 return -1; … … 128 155 return 1; 129 156 } 157 158 130 159 131 160 /** Copy NULL terminated string. -
kernel/kernel.config
r16529d5 r28ecadb 36 36 @ "indy" SGI Indy 37 37 ! [ARCH=mips32] MACHINE (choice) 38 39 # Machine type40 @ "ultra" Sun Ultra 541 @ "enterprise" Sun Enterprise E650042 ! [ARCH=sparc64] MACHINE (choice)43 38 44 39 # Framebuffer support … … 111 106 ! [ARCH=sparc64] CONFIG_TSB (n/y) 112 107 108 # Support for Z8530 serial port 109 ! [ARCH=sparc64] CONFIG_Z8530 (y/n) 110 111 # Support for NS16550 serial port 112 ! [ARCH=sparc64] CONFIG_NS16550 (y/n) 113 113 114 ## Run-time configuration directives 114 115
Note:
See TracChangeset
for help on using the changeset viewer.