Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1895 → Rev 1896

/trunk/boot/genarch/ofw_tree.c
47,7 → 47,22
 
static void * ofw_tree_space_alloc(size_t size)
{
return balloc(size, size);
char *addr;
 
/*
* 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.
*/
addr = balloc(size + 1, size);
if (addr)
addr[size] = '\0';
return addr;
}
 
/** Transfer information from one OpenFirmware node into its memory representation.
153,7 → 168,8
if (i == current_node->properties)
break;
strncpy(current_node->property[i].name, name, sizeof(name));
memcpy(current_node->property[i].name, name, OFW_TREE_PROPERTY_MAX_NAMELEN);
current_node->property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0';
 
size = ofw_get_proplen(current, name);
current_node->property[i].size = size;
/trunk/boot/generic/string.c
57,6 → 57,34
*
* 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.
*
71,8 → 99,7
{
int i;
i = 0;
for (;*src && *dst && i < len;src++,dst++,i++) {
for (i = 0; *src && *dst && i < len; src++, dst++, i++) {
if (*src < *dst)
return -1;
if (*src > *dst)
/trunk/boot/generic/string.h
38,6 → 38,7
#include <types.h>
 
extern size_t strlen(const char *str);
extern int strcmp(const char *src, const char *dst);
extern int strncmp(const char *src, const char *dst, size_t len);
extern void strncpy(char *dest, const char *src, size_t len);
extern unative_t atoi(const char *text);
/trunk/boot/arch/sparc64/loader/main.c
65,9 → 65,6
/* transform scanline to bytes with respect to potential alignment */
bootinfo.screen.scanline = bootinfo.screen.scanline*bpp2align[bootinfo.screen.bpp >> 3];
if (!ofw_keyboard(&bootinfo.keyboard))
printf("Error: unable to get keyboard properties\n");
 
if (!ofw_cpu(&bootinfo.cpu))
printf("Error: unable to get cpu properties\n");
 
75,7 → 72,6
printf(" cpu: %dMHz\n", bootinfo.cpu.clock_frequency/1000000);
printf(" memory: %dM\n", bootinfo.memmap.total>>20);
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);
printf(" keyboard at %P (size %d bytes)\n", (uintptr_t) bootinfo.keyboard.addr, bootinfo.keyboard.size);
 
printf("\nMemory statistics\n");
printf(" kernel entry point at %P\n", KERNEL_VIRTUAL_ADDRESS);
/trunk/boot/arch/sparc64/loader/main.h
54,7 → 54,6
taskmap_t taskmap;
memmap_t memmap;
screen_t screen;
keyboard_t keyboard;
cpu_t cpu;
ballocs_t ballocs;
ofw_tree_node_t *ofw_root;
/trunk/boot/arch/sparc64/loader/ofwarch.c
95,7 → 95,7
for (; node != 0 && node != -1; node = ofw_get_peer_node(node)) {
if (ofw_get_property(node, "device_type", type_name, sizeof(type_name)) > 0) {
if (strncmp(type_name, "cpu", 3) == 0) {
if (strcmp(type_name, "cpu") == 0) {
uint32_t mhz;
if (ofw_get_property(node, "clock-frequency", &mhz, sizeof(mhz)) <= 0)