U0 SysGlblsInit() { I64 i,j; CRAXRBXRCXRDX ee; CPUId(0x1,&ee); sys_cache_line_width=ee.rbx.u8[1]*8; CPUId(0x40000000,&ee); hype_info[0]=ee.rbx.u32[0]; hype_info[1]=ee.rcx.u32[0]; hype_info[2]=ee.rdx.u32[0]; hype_info[3]=0; SetSysFocusTask; QueInit(&sys_macro_head); blkdev.dft_iso_filename =AStrNew(DFT_ISO_FILENAME); blkdev.dft_iso_c_filename =AStrNew(DFT_ISO_C_FILENAME); blkdev.tmp_filename =AStrNew("~/Tmp.DD.Z"); blkdev.dvd_boot_is_good=TRUE; #exe { if (!kernel_cfg->mount_ide_auto_hd_let) kernel_cfg->mount_ide_auto_hd_let='C'; if (!kernel_cfg->mount_ide_auto_cd_let) kernel_cfg->mount_ide_auto_cd_let='T'; StreamPrint("blkdev.first_hd_drv_let=%d;", kernel_cfg->mount_ide_auto_hd_let); StreamPrint("blkdev.first_dvd_drv_let=%d;", kernel_cfg->mount_ide_auto_cd_let); } DbgMode(ON); rev_bits_table=CAlloc(256); set_bits_table=CAlloc(256); key_state=CAlloc(128); sc_state=CAlloc(256); sc_flags_state=0; for (i=0; i<256; i++) { for (j=0; j<8; j++) { if (Bt(&i,7-j)) LBts(rev_bits_table+i,j); if (Bt(&i,j)) set_bits_table[i]++; } } ext=CAlloc(EXT_EXTS_NUM*sizeof(U8 *)); fp_getstr2=&SysGetStr2; KeyDevInit; #exe { StreamPrint("blkdev.boot_drv_let='%C';",kernel_cfg->boot_drv_let); StreamPrint("#exe{Option(OPTf_WARN_PAREN,OFF);}"); StreamPrint("DskCacheInit(%s);",kernel_cfg->dsk_cache_size_exp); StreamPrint("#exe{Option(OPTf_WARN_PAREN,ON);}"); }; pow10_I64=CAlloc(sizeof(F64)*(308+308+1)); for (i=-308; i<309; i++) pow10_I64[i+309]=Pow10(i); QueInit(&scrncast.snd_head); scrncast.t0_now=Now; scrncast.t0_tS=tS; scrncast.ona=scrncast.snd_head.ona=0; snd.ona=ONA_REST; snd.fp_alt_snd_dev=NULL; QueInit(&snd.record_head); snd.record_head.time=tS; ProgressBarsRst; QueInit(&dev.pci_head); dev.mem64_ptr=mem_mapped_space; dbg.fun_seg_cache=CAlloc(FUN_SEG_CACHE_SIZE*sizeof(CFunSegCache)); dbg.int_fault_code=IntFaultHndlrsNew; MemSet(sys_usb_devs,0,USB_NUM*sizeof(CUSB)); sys_num_usb=0; for (i=0; i<26; i++) BlkDevLtrOverride[i]=BDT_NULL; } U0 SysGrInit() { text.font=sys_font_std; text.aux_font=sys_font_cyrillic; if (!Bt(&sys_run_level,RLf_VGA)) //if text mode { text.cols=80; text.rows=25; text.vga_alias =dev.uncached_alias+VGAM_GRAPHICS; text.vga_text_alias =dev.uncached_alias+VGAM_TEXT; MemSet(text.vga_text_alias,0,text.rows*text.cols<<1); text.border_chars[2] (I64)='........'; text.border_chars[10](U32)='....'; } else //if 640x480 16 color { text.cols = GR_WIDTH / FONT_WIDTH; text.rows = GR_HEIGHT / FONT_HEIGHT; text.screen_size = GR_WIDTH * GR_HEIGHT; text.buffer_size = text.screen_size * 4; text.raw_scrn_image = CAllocAligned(text.buffer_size,16); text.raw_scrn_img2 = CAllocAligned(FB_HEIGHT*sys_vbe_mode_pitch,16); text.fb_alias = sys_frame_buffer; MemSetU32(text.fb_alias, BLACK32, FB_HEIGHT*sys_vbe_mode_pitch/4); text.vga_alias = CAlloc(text.rows * text.cols * 8); text.border_chars[2] (I64)=0x0908070605040302; text.border_chars[10](U32)=0x0D0C0B0A; } } U0 TimersInit() { OutU8(0x43,0x34); OutU8(0x40,SYS_TIMER0_PERIOD); OutU8(0x40,SYS_TIMER0_PERIOD>>8); } U0 Reboot() {//Hardware reset. CLI if (mp_cnt>1) MPHalt; *0x472(U16 *)=0; OutU8(0x70,0x8F); OutU8(0x71,0x00); OutU8(0x70,0x00); OutU8(0x92,InU8(0x92)|1); SysHlt; } U0 KMain() {//Continued from KStart64.HC CBlkDev *bd, *initramfs; OutU8(0x61,InU8(0x61)&~3); //Snd; adam_task=Fs; BlkPoolsInit; SysGlblsInit; Mem32DevInit; UncachedAliasAlloc; LoadKernel; SysGrInit; StrCpy(Fs->task_name,"Adam Task CPU00"); StrCpy(Fs->task_title,Fs->task_name); Fs->title_src=TTS_TASK_NAME; Fs->win_right=text.cols-2; Fs->win_top++; TaskDerivedValsUpdate; SysDefinesLoad; Core0Init; IntInit1; //Before this point use Snd() and Busy() //to debug. After this point, use RawPrint() LBts(&sys_run_level,RLf_RAW); "TinkerOS V%5.3f\t%D %T\n\n" , sys_os_version,sys_compile_time,sys_compile_time; TimersInit; if (BIOSTotalMem<ToI64(0.95*MEM_MIN_MEG*0x100000)) RawPrint(4000,"!!! Requires 1024Meg of RAM Memory !!!"); IntsInit; "Enable IRQ's\n"; IntInit2; WBINVD; Busy(200); SetRFlags(RFLAGG_NORMAL); Busy(2000); LBts(&sys_run_level,RLf_INTERRUPTS); TimeCal; try { BlkDevsInitAll; } catch { "Failed to initialize expected block devices!\n"; "You probably compiled your kernel with the wrong\n"; "settings, boot cannot continue!\n\n"; throw('NoBlkDev'); } if (sys_initramfs_ptr && sys_initramfs_size) { if (DrvMounted('B')) { Unmount('B'); } initramfs=BlkDevNextFreeSlot('B',1); initramfs->first_drv_let='B'; initramfs->type=BDT_RAM; initramfs->RAM_dsk=sys_initramfs_ptr; initramfs->max_blk=sys_initramfs_size>>BLK_SIZE_BITS-1; initramfs->drv_offset=19<<2+(DVD_BLK_SIZE*2+DVD_BOOT_LOADER_SIZE)/BLK_SIZE; BlkDevAdd(initramfs,I64_MIN,0,1); DskChg('B'); Silent(ON); DirMk("B:/Home"); DirMk("B:/Tmp"); Silent(OFF); } "DskChg(':');\n"; DskChg(':'); #exe { StreamPrint("HomeSet(\"%s\");\n" "blkdev.ins_base0=%d;blkdev.ins_base1=%d;blkdev.ins_unit =%d;\n", kernel_cfg->home_dir, blkdev.ins_base0,blkdev.ins_base1,blkdev.ins_unit); } Gs->idle_task->cur_dv=blkdev.let_to_drv[*blkdev.home_dir-'A']; DrvRep; if (blkdev.dvd_boot_is_good) { bd=Let2BlkDev(':'); if (bd->type==BDT_ATAPI || bd->type==BDT_AHCI_SATAPI) { blkdev.ins_base0=bd->base0; blkdev.ins_base1=bd->base1; blkdev.ins_unit =bd->unit; } } LBts(&sys_run_level,RLf_BLKDEV); #exe { if (!kernel_cfg->opts[CFG_NO_MP]) StreamPrint("\"MultiCore Start\\n\\n\";" "Core0StartMP;" "LBts(&sys_run_level,RLf_MP);"); }; KbdMsInit; MsInit; KbdInit; Spawn(&MsHardDrvrInstall); Silent(OFF); "Loading Compiler\n"; Cd("/Compiler"); Load("Compiler",LDF_SILENT); LBts(&sys_run_level,RLf_COMPILER); DbgMode(OFF); cnts.time_stamp_freq_initial=TimeCal; Cd("/"); try ExeFile("StartOS"); //Continues /StartOS.HC catch { Raw(ON); Silent(OFF); GetOutOfDollar; PutExcept; Dbg; } LBts(&sys_run_level,RLf_ADAM_SERVER); SrvTaskCont; //Never to return } asm { ALIGN 16,OC_NOP SYS_KERNEL_END:: #exe { if (kernel_cfg->opts[CFG_DBG_DISTRO]) StreamPrint("DU8 0x%X-(SYS_KERNEL_END-SYS_KERNEL+" "BOOT_RAM_BASE+sizeof(CBinFile)) DUP (0);" "BINFILE \"%s\";",kernel_cfg->dbg_distro_start, kernel_cfg->dbg_distro_file); }; }