static void ioCluster_init(struct cluster_s *cluster, uint_t id) { struct device_s *pic; int i; /* First of all: Initialize TTYs */ ibmpc_tty_init(&ttys_tbl[0], __tty_addr, 1, 0); // IRQ 0 is taken by Timer 0 boot_dmsg("\nSetup Terminal \t\t\t\tOK\n"); cluster_init(cluster, id, __CPU_NR); boot_dmsg("Setup PIC "); pic = kbootMem_calloc(sizeof(*pic)); ibmpc_pic_init(pic, __pic_addr, 0); ibmpc_pic_bind(pic, &ttys_tbl[0]); devfs_register(&ttys_tbl[0]); for(i=0; i < __CPU_NR; i++) arch_cpu_set_irq_entry(&cluster->cpu_tbl[i], 0, &pic->action); boot_dmsg("\t\t\t\tOK\nSetup Timer "); rt_timer_init(TIC, 1); ibmpc_pic_bind(pic, &rt_timer); boot_dmsg("\t\t\t\tOK\nSetup H.D.D "); ibmpc_ata_init(&__sys_blk, (void*)ATA0_DRIVE0, 14); ibmpc_pic_bind(pic, &__sys_blk); boot_dmsg("\t\t\t\tOK\nActivating IRQs"); pic->op.icu.set_mask(pic, ICU_MASK, 0, 0); boot_dmsg("\t\t\t\tOK\n"); }
static void boot_signal_op(struct boot_info_s *info, uint_t cpu_nr) { bsb_t *bsb; struct arch_bib_header_s *header; uint_t *tty; header = (struct arch_bib_header_s*) info->arch_info; tty = (uint_t*) header->bootstrap_tty; if((info == NULL) || (cpu_nr > info->onln_cpu_nr)) { boot_dmsg(tty, "ERROR: %s: Invalid Arguments [0x%x, %d]\n", info, cpu_nr); while(1); } bsb = (bsb_t*) info->data; bsb->cpu_count = cpu_nr; bsb->boot_signal = CONFIG_BOOT_SIGNAL_SIGNATURE; cpu_wbflush(); }
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 = '!'; } }