Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1898 → Rev 1899

/trunk/boot/genarch/ofw.h
90,7 → 90,6
 
extern uintptr_t ofw_cif;
 
 
extern phandle ofw_chosen;
extern ihandle ofw_stdout;
extern phandle ofw_root;
113,6 → 112,7
extern int ofw_package_to_path(const phandle device, char *buf, const int buflen);
 
extern int ofw(ofw_args_t *arg);
extern unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...);
extern unsigned int ofw_get_address_cells(const phandle device);
extern unsigned int ofw_get_size_cells(const phandle device);
extern void *ofw_translate(const void *virt);
/trunk/boot/genarch/ofw.c
83,7 → 83,7
*
* @return Return value returned by the client interface.
*/
static unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
{
va_list list;
ofw_args_t args;
/trunk/boot/arch/sparc64/loader/ofwarch.h
34,8 → 34,6
#define OFW_ADDRESS_CELLS 2
#define OFW_SIZE_CELLS 2
 
extern int bpp2align[];
extern int ofw_cpu(void);
 
extern int ofw_cpu(cpu_t *cpu);
 
#endif
/trunk/boot/arch/sparc64/loader/asm.S
100,6 → 100,7
mov %o0, %l1
mov %o1, %o0
mov %o2, %o1
mov %o3, %o2
jmp %l1 ! jump to kernel
nop
 
/trunk/boot/arch/sparc64/loader/main.c
36,8 → 36,6
#include "ofwarch.h"
#include <align.h>
 
#define KERNEL_VIRTUAL_ADDRESS 0x400000
 
bootinfo_t bootinfo;
 
void bootstrap(void)
57,11 → 55,7
halt();
}
if (!ofw_cpu(&bootinfo.cpu))
printf("Error: unable to get cpu properties\n");
 
printf("\nDevice info\n");
printf(" cpu: %dMHz\n", bootinfo.cpu.clock_frequency/1000000);
printf("\nSystem info\n");
printf(" memory: %dM\n", bootinfo.memmap.total>>20);
 
printf("\nMemory statistics\n");
96,6 → 90,11
bootinfo.ofw_root = ofw_tree_build();
printf("done.\n");
 
printf("\nChecking for secondary processors...");
if (!ofw_cpu())
printf("Error: unable to get cpu properties\n");
printf("done.\n");
 
printf("\nBooting the kernel...\n");
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo));
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 1, &bootinfo, sizeof(bootinfo));
}
/trunk/boot/arch/sparc64/loader/asm.h
35,6 → 35,6
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))
 
extern void halt(void);
extern void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
extern void jump_to_kernel(void *entry, int bsp, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
 
#endif
/trunk/boot/arch/sparc64/loader/main.h
34,6 → 34,8
#include <balloc.h>
#include <types.h>
 
#define KERNEL_VIRTUAL_ADDRESS 0x400000
 
#define TASKMAP_MAX_RECORDS 32
 
typedef struct {
47,13 → 49,8
} taskmap_t;
 
typedef struct {
uint32_t clock_frequency;
} cpu_t;
 
typedef struct {
taskmap_t taskmap;
memmap_t memmap;
cpu_t cpu;
ballocs_t ballocs;
ofw_tree_node_t *ofw_root;
} bootinfo_t;
/trunk/boot/arch/sparc64/loader/ofwarch.c
53,7 → 53,12
return flag != -1;
}
 
int ofw_cpu(cpu_t *cpu)
 
#define ASI_UPA_CONFIG 0x4a
#define UPA_CONFIG_MID_SHIFT 17
#define UPA_CONFIG_MID_MASK 0x1f
 
int ofw_cpu(void)
{
char type_name[BUF_SIZE];
 
61,22 → 66,32
node = ofw_get_child_node(ofw_root);
if (node == 0 || node == -1) {
printf("Could not find any child nodes of the root node.\n");
return;
return 0;
}
uint64_t current_mid;
__asm__ volatile ("ldxa [%1] %2, %0\n" : "=r" (current_mid) : "r" (0), "i" (ASI_UPA_CONFIG));
current_mid >>= UPA_CONFIG_MID_SHIFT;
current_mid &= UPA_CONFIG_MID_MASK;
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 (strcmp(type_name, "cpu") == 0) {
uint32_t mhz;
uint32_t mid;
if (ofw_get_property(node, "clock-frequency", &mhz, sizeof(mhz)) <= 0)
if (ofw_get_property(node, "upa-portid", &mid, sizeof(mid)) <= 0)
continue;
cpu->clock_frequency = mhz;
return 1;
if (current_mid != mid) {
/*
* Start secondary processor.
*/
(void) ofw_call("SUNW,start-cpu", 3, 1, NULL, node, KERNEL_VIRTUAL_ADDRESS, 0);
}
}
}
};
}
 
return 0;
return 1;
}