void cpu_reset(void) { static char bspec[64] = ""; phandle_t chosen; static struct { cell_t name; cell_t nargs; cell_t nreturns; cell_t bootspec; } args = { (cell_t)"boot", 1, 0, (cell_t)bspec }; if ((chosen = OF_finddevice("/chosen")) != -1) { if (OF_getprop(chosen, "bootpath", bspec, sizeof(bspec)) == -1) bspec[0] = '\0'; bspec[sizeof(bspec) - 1] = '\0'; } cpu_shutdown(&args); }
int csp_sys_shutdown(void) { extern void __attribute__((weak)) cpu_shutdown(void); if (cpu_shutdown) { cpu_shutdown(); while (1); } csp_log_error("Failed to shutdown"); return CSP_ERR_INVAL; }
static void boot_loader(int cpu_id) { uint_t *src; uint_t *dst; uint_t size; boot_info_t boot_info; boot_info_t *info; boot_tbl_entry_t *boot_tbl; struct arch_bib_header_s *header; volatile bsb_t *bsb; kernel_info_t *kinfo; uint_t cpu_nr; uint_t *tty; uint_t *dma_base; uint_t cpu_lid; uint_t cid; uint_t local_cpu_nr; uint_t local_onln_cpu_nr; cluster_info_t *clusters; header = (struct arch_bib_header_s*) ARCH_BIB_BASE; kinfo = (kernel_info_t*) KERNEL_HEADER; if(strcmp(header->signature, arch_bib_signature)) while(1); /* no other way to die !! */ tty = (uint_t*) header->bootstrap_tty; bsb = (volatile bsb_t *)(header->rsrvd_limit - CONFIG_BSB_OFFSET); local_cpu_nr = header->cpu_nr; cid = cpu_id / local_cpu_nr; cpu_lid = cpu_id % local_cpu_nr; clusters = (cluster_info_t*) ((uint_t)header + sizeof(header_info_t)); local_onln_cpu_nr = clusters[cid].cpu_nr; if(cpu_id == header->bootstrap_cpu) { if(kinfo->signature != KERNEL_SIGNATURE) while(1); cpu_nr = header->onln_cpu_nr; boot_dmsg(tty, "\nAlmOS Bootloader\t\t\t[ STARTED ]\n\n"); memset((void*)bsb, 0, sizeof(*bsb)); src = (uint_t *) kinfo; dst = (uint_t *) header->rsrvd_start; size = kinfo->data_end - kinfo->text_start; dma_base = (uint_t*) header->bootstrap_dma; boot_dmsg(tty, "Loading Kernel Image"); boot_memcpy(dma_base, dst, src, size); boot_dmsg(tty, "\t\t\t[ OK ]\nLoading Boot Information Block"); info = &((bsb_t*)bsb)->info; size = ARROUND_UP(header->size, 0x1000); info->reserved_start = header->rsrvd_limit - 0x1000 - size; info->arch_info = info->reserved_start; boot_memcpy(dma_base, (uint_t*)info->arch_info, header, header->size); boot_dmsg(tty, "\t\t[ OK ]\nSetup Kernel Boot Information"); size = (sizeof(boot_tbl_entry_t) * header->onln_clstr_nr); size = ARROUND_UP(size, 0x1000); info->reserved_start -= size; info->boot_tbl = info->reserved_start; bsb->boot_tbl = info->boot_tbl; info->text_start = header->rsrvd_start; info->text_end = (kinfo->text_end - kinfo->text_start) + info->text_start; info->data_start = (kinfo->data_start - kinfo->text_start) + info->text_start; info->data_end = (kinfo->data_end - kinfo->text_start) + info->text_start; info->brom_start = CONFIG_BROM_START; info->brom_end = CONFIG_BROM_END; info->reserved_end = header->rsrvd_limit; info->onln_cpu_nr = cpu_nr; info->onln_clstr_nr = header->onln_clstr_nr; info->local_cpu_nr = local_cpu_nr; info->local_onln_cpu_nr = local_onln_cpu_nr; info->local_cpu_id = cpu_lid; info->local_cluster_id = cid; info->boot_cluster_id = cid; info->boot_cpu_id = cpu_id; info->boot_signal = &boot_signal_op; info->data = (void*)bsb; boot_dmsg(tty, "\t\t[ OK ]\nPreparing Kernel's Memory Layout"); memory_init(tty, info, kinfo); boot_dmsg(tty, "\t[ OK ]\n\nBooting AlmOS Kernel ...\n\n", info->boot_cluster_id, info->boot_cpu_id); boot_dmsg(tty, "Boot Info:\n\tArch Info %x\n\tText <0x%x : 0x%x>\n\tData <0x%x : 0x%x>\n\tReserved <0x%x : 0x%x>\n\tBSC %d, BSP %d, CPU NR %d, MMU ON\n", info->arch_info, info->text_start, info->text_end, info->data_start, info->data_end, info->reserved_start, info->reserved_end, info->boot_cluster_id, info->boot_cpu_id, info->onln_cpu_nr); boot_dmsg(tty, "\tKernel Entry Point @0x%x\n\n", kinfo->entry_addr); mmu_activate(info->boot_pgdir, kinfo->entry_addr, (uint_t)info); *tty = '?'; } else { info = &boot_info; memcpy(info, &((bsb_t*)bsb)->info, sizeof(*info)); boot_tbl = (boot_tbl_entry_t*)info->boot_tbl; info->reserved_end = boot_tbl[cid].reserved_end; info->reserved_start = boot_tbl[cid].reserved_start; info->local_cpu_nr = local_cpu_nr; info->local_onln_cpu_nr = local_onln_cpu_nr; info->local_cpu_id = cpu_lid; info->local_cluster_id = cid; if(bsb->cpu_count <= cpu_id) cpu_shutdown(); cpu_goto_entry(kinfo->entry_addr, (uint_t)info); *tty = '!'; } }