2020-02-16 00:09:08 +00:00
|
|
|
|
U0 SysGlobalsInit()
|
2020-02-15 20:01:48 +00:00
|
|
|
|
{
|
|
|
|
|
I64 i,j;
|
2020-02-16 07:26:36 +00:00
|
|
|
|
CRAXRBCRCXRDX regs;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
|
2020-02-16 07:26:36 +00:00
|
|
|
|
CPUId(0x1,®s);
|
|
|
|
|
sys_cache_line_width=regs.rbx.u8[1]*8;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
|
|
|
|
|
sys_focus_task=Fs;
|
2020-02-15 22:53:02 +00:00
|
|
|
|
QueueInit(&sys_macro_head);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
|
2020-02-16 02:38:13 +00:00
|
|
|
|
blkdev.default_iso_filename =ZStrNew(DEFAULT_ISO_FILENAME);
|
|
|
|
|
blkdev.default_iso_c_filename =ZStrNew(DEFAULT_ISO_C_FILENAME);
|
|
|
|
|
blkdev.tmp_filename =ZStrNew("~/Tmp.DD");
|
2020-02-15 20:01:48 +00:00
|
|
|
|
blkdev.dvd_boot_is_good=TRUE;
|
|
|
|
|
#exe {
|
2020-02-16 03:06:00 +00:00
|
|
|
|
if (!kernel_config->mount_ide_auto_hd_let)
|
|
|
|
|
kernel_config->mount_ide_auto_hd_let='C';
|
|
|
|
|
if (!kernel_config->mount_ide_auto_cd_let)
|
|
|
|
|
kernel_config->mount_ide_auto_cd_let='T';
|
2020-02-16 02:31:50 +00:00
|
|
|
|
StreamPrint("blkdev.first_hd_drive_let=%d;",
|
2020-02-16 03:06:00 +00:00
|
|
|
|
kernel_config->mount_ide_auto_hd_let);
|
2020-02-16 02:31:50 +00:00
|
|
|
|
StreamPrint("blkdev.first_dvd_drive_let=%d;",
|
2020-02-16 03:06:00 +00:00
|
|
|
|
kernel_config->mount_ide_auto_cd_let);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 22:25:33 +00:00
|
|
|
|
DebugMode(ON);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
rev_bits_table=CAlloc(256);
|
|
|
|
|
set_bits_table=CAlloc(256);
|
|
|
|
|
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 {
|
2020-02-16 03:06:00 +00:00
|
|
|
|
StreamPrint("blkdev.boot_drive_let='%C';",kernel_config->boot_drive_let);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
StreamPrint("#exe{Option(OPTf_WARN_PAREN,OFF);}");
|
2020-02-16 03:06:00 +00:00
|
|
|
|
StreamPrint("DiskCacheInit(%s);",kernel_config->disk_cache_size_exp);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
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);
|
|
|
|
|
|
2020-02-16 00:49:37 +00:00
|
|
|
|
QueueInit(&screencast.sound_head);
|
|
|
|
|
screencast.t0_now=Now;
|
|
|
|
|
screencast.t0_tS=tS;
|
|
|
|
|
screencast.ona=screencast.sound_head.ona=0;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
|
2020-02-16 00:54:39 +00:00
|
|
|
|
ProgressBarsReset;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
|
2020-02-15 22:53:02 +00:00
|
|
|
|
QueueInit(&dev.pci_head);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
dev.mem64_ptr=mem_mapped_space;
|
|
|
|
|
|
2020-02-16 07:26:36 +00:00
|
|
|
|
Seg2Linear(SYS_FONT_PTR);
|
|
|
|
|
|
2020-02-16 03:37:50 +00:00
|
|
|
|
debug.fun_seg_cache=CAlloc(FUN_SEG_CACHE_SIZE*sizeof(CFunSegCache));
|
|
|
|
|
debug.int_fault_code=IntFaultHandlersNew;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
U0 SysGrInit()
|
|
|
|
|
{
|
2020-02-16 07:26:36 +00:00
|
|
|
|
I64 i, j;
|
|
|
|
|
text.font = MAlloc(256 * 8); //256 U64s
|
|
|
|
|
MemCopy(text.font, *SYS_FONT_PTR(U32), 256 * 8);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
|
for (j = 0; j < 8; j++)
|
|
|
|
|
text.font[i].u8[j] = rev_bits_table[text.font[i].u8[j]];
|
|
|
|
|
|
|
|
|
|
text.aux_font=sys_font_std;
|
|
|
|
|
text.font['' - 1] = text.aux_font['' - 1]; //Shift-space
|
|
|
|
|
text.font[10] = text.aux_font[10]; //"Return" symbol
|
|
|
|
|
text.font[255] = text.aux_font[255]; //auxillary block character
|
|
|
|
|
|
|
|
|
|
text.border_chars[2] (I64)='<EFBFBD>ͳ<EFBFBD><EFBFBD>ɿ<EFBFBD>';
|
2020-02-16 08:00:07 +00:00
|
|
|
|
text.border_chars[10](U32)='<EFBFBD><EFBFBD>ټ';
|
2020-02-15 20:01:48 +00:00
|
|
|
|
text.vga_alias =dev.uncached_alias+VGAM_GRAPHICS;
|
|
|
|
|
text.vga_text_alias =dev.uncached_alias+VGAM_TEXT;
|
|
|
|
|
if (!Bt(&sys_run_level,RLf_VGA)) { //if text mode
|
|
|
|
|
text.cols=80;
|
|
|
|
|
text.rows=25;
|
|
|
|
|
MemSet(text.vga_text_alias,0,text.rows*text.cols<<1);
|
|
|
|
|
} else { //if 640x480 16 color
|
|
|
|
|
text.cols=GR_WIDTH/FONT_WIDTH;
|
|
|
|
|
text.rows=GR_HEIGHT/FONT_HEIGHT;
|
|
|
|
|
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
|
|
|
|
OutU8(VGAP_DATA,0x0F);
|
|
|
|
|
MemSet(text.vga_alias,0,GR_WIDTH*GR_HEIGHT>>3);
|
2020-02-16 05:24:10 +00:00
|
|
|
|
text.raw_screen_image=CAlloc(GR_WIDTH*GR_HEIGHT/8);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
U0 TimersInit()
|
|
|
|
|
{
|
|
|
|
|
I64 i,*_q;
|
|
|
|
|
U32 *_d;
|
|
|
|
|
|
2020-02-16 10:19:49 +00:00
|
|
|
|
OutU8(PIT_CMD, PIT_CMDF_CHANNEL0 | PIT_CMDF_OPMODE_RATE_GEN | PIT_CMDF_ACCESS_WORD);
|
|
|
|
|
OutU8(PIT0,SYS_TIMER0_PERIOD);
|
|
|
|
|
OutU8(PIT0,SYS_TIMER0_PERIOD >> 8);
|
|
|
|
|
|
2020-02-15 20:01:48 +00:00
|
|
|
|
//High Precision Event Timer
|
|
|
|
|
if (PCIReadU16(0,31,0,0)==0x8086) {//Intel?
|
2020-02-16 03:06:00 +00:00
|
|
|
|
//D31 F0, config 0xF0=RCBA of PCI-LPC Bridge
|
|
|
|
|
_d=PCIReadU32(0,31,0,0xF0)(U8 *)&~0x3FFF+0x3404; //HPET config
|
2020-02-15 20:01:48 +00:00
|
|
|
|
//7 enable
|
|
|
|
|
//1:0 HPET is at 0xFED00000,0xFED01000, 0xFED02000 or 0xFED03000.
|
|
|
|
|
*_d=*_d&3|0x80;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_q=dev.uncached_alias+HPET_GCAP_ID;
|
|
|
|
|
i=*_q; //i.u32[1]= period in femtoS (10e-15)
|
|
|
|
|
if (100000<i.u32[1]<1000000000) {
|
2020-02-16 00:20:04 +00:00
|
|
|
|
counts.HPET_freq =1000000000000000/i.u32[1];
|
|
|
|
|
counts.HPET_kHz_freq=1000000000000/i.u32[1];
|
2020-02-15 20:01:48 +00:00
|
|
|
|
_q=dev.uncached_alias+HPET_GEN_CONF;
|
|
|
|
|
*_q|=1; //Enable counting
|
2020-02-16 00:20:04 +00:00
|
|
|
|
counts.HPET_initial=HPET;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
} else {
|
2020-02-16 00:20:04 +00:00
|
|
|
|
counts.HPET_freq=0;
|
|
|
|
|
counts.HPET_kHz_freq=0;
|
|
|
|
|
counts.HPET_initial=0;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 09:56:39 +00:00
|
|
|
|
U0 Reboot(Bool format_ramdisks=FALSE)
|
2020-02-15 20:01:48 +00:00
|
|
|
|
{//Hardware reset.
|
2020-02-16 09:56:39 +00:00
|
|
|
|
if (format_ramdisks)
|
|
|
|
|
{
|
|
|
|
|
if (DriveIsWritable('A'))
|
|
|
|
|
Format('A',,FALSE,FSt_REDSEA);
|
|
|
|
|
if (DriveIsWritable('B'))
|
|
|
|
|
Format('B',,FALSE,FSt_REDSEA);
|
2020-02-16 10:19:49 +00:00
|
|
|
|
}
|
2020-02-15 20:01:48 +00:00
|
|
|
|
CLI
|
2020-02-16 00:20:04 +00:00
|
|
|
|
if (mp_count>1)
|
2020-02-15 20:01:48 +00:00
|
|
|
|
MPHalt;
|
|
|
|
|
*0x472(U16 *)=0;
|
|
|
|
|
OutU8(0x70,0x8F);
|
|
|
|
|
OutU8(0x71,0x00);
|
|
|
|
|
OutU8(0x70,0x00);
|
|
|
|
|
OutU8(0x92,InU8(0x92)|1);
|
|
|
|
|
SysHlt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
U0 KMain()
|
2020-02-16 04:57:03 +00:00
|
|
|
|
{//Continued from $LK,"KStart64.CC",A="FF:::/Kernel/KStart64.CC,I32 &KMain"$
|
2020-02-15 20:01:48 +00:00
|
|
|
|
CBlkDev *bd;
|
2020-02-16 00:49:37 +00:00
|
|
|
|
OutU8(0x61,InU8(0x61)&~3); //Sound;
|
2020-02-15 22:25:33 +00:00
|
|
|
|
zenith_task=Fs;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
BlkPoolsInit;
|
2020-02-16 00:09:08 +00:00
|
|
|
|
SysGlobalsInit;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
Mem32DevInit;
|
|
|
|
|
UncachedAliasAlloc;
|
|
|
|
|
LoadKernel;
|
|
|
|
|
SysGrInit;
|
2020-02-16 03:32:01 +00:00
|
|
|
|
StrCopy(Fs->task_name,"Zenith Task CPU00");
|
|
|
|
|
StrCopy(Fs->task_title,Fs->task_name);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
Fs->title_src=TTS_TASK_NAME;
|
|
|
|
|
Fs->win_right=text.cols-2;
|
|
|
|
|
Fs->win_top++;
|
|
|
|
|
TaskDerivedValsUpdate;
|
|
|
|
|
|
|
|
|
|
SysDefinesLoad;
|
|
|
|
|
Core0Init;
|
|
|
|
|
IntInit1;
|
|
|
|
|
|
2020-02-16 00:49:37 +00:00
|
|
|
|
//Before this point use $LK,"Sound",A="MN:Sound"$() and $LK,"Busy",A="MN:Busy"$()
|
2020-02-15 20:01:48 +00:00
|
|
|
|
//to debug.After this point, use $LK,"RawPrint",A="MN:RawPrint"$()
|
|
|
|
|
LBts(&sys_run_level,RLf_RAW);
|
2020-02-15 21:11:16 +00:00
|
|
|
|
"ZenithOS V%5.3f\t%D %T\n\n",
|
2020-02-15 20:01:48 +00:00
|
|
|
|
sys_os_version,sys_compile_time,sys_compile_time;
|
|
|
|
|
|
|
|
|
|
TimersInit;
|
|
|
|
|
if (BIOSTotalMem<ToI64(0.95*MEM_MIN_MEG*0x100000))
|
|
|
|
|
RawPrint(4000,"!!! Requires $TX,"512Meg",D="DD_MEM_MIN_MEG"$ of RAM Memory !!!");
|
|
|
|
|
|
|
|
|
|
IntsInit;
|
|
|
|
|
"Enable IRQ's\n";
|
|
|
|
|
SetRFlags(RFLAGG_NORMAL);
|
|
|
|
|
Busy(2000);
|
|
|
|
|
IntInit2;
|
|
|
|
|
LBts(&sys_run_level,RLf_INTERRUPTS);
|
|
|
|
|
|
|
|
|
|
TimeCal;
|
|
|
|
|
BlkDevsInitAll;
|
2020-02-16 02:31:50 +00:00
|
|
|
|
"DiskChange(':');\n";
|
|
|
|
|
DiskChange(':');
|
2020-02-15 20:01:48 +00:00
|
|
|
|
#exe {
|
|
|
|
|
StreamPrint("HomeSet(\"%s\");\n"
|
|
|
|
|
"blkdev.ins_base0=%d;blkdev.ins_base1=%d;blkdev.ins_unit =%d;\n",
|
2020-02-16 03:06:00 +00:00
|
|
|
|
kernel_config->home_dir,
|
2020-02-15 20:01:48 +00:00
|
|
|
|
blkdev.ins_base0,blkdev.ins_base1,blkdev.ins_unit);
|
|
|
|
|
}
|
2020-02-16 02:31:50 +00:00
|
|
|
|
Gs->idle_task->cur_dv=blkdev.let_to_drive[*blkdev.home_dir-'A'];
|
2020-02-15 22:53:02 +00:00
|
|
|
|
DriveRep;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
if (blkdev.dvd_boot_is_good) {
|
2020-02-15 22:53:02 +00:00
|
|
|
|
bd=Letter2BlkDev(':');
|
2020-02-15 20:01:48 +00:00
|
|
|
|
if (bd->type==BDT_ATAPI) {
|
|
|
|
|
blkdev.ins_base0=bd->base0;
|
|
|
|
|
blkdev.ins_base1=bd->base1;
|
|
|
|
|
blkdev.ins_unit =bd->unit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LBts(&sys_run_level,RLf_BLKDEV);
|
|
|
|
|
|
|
|
|
|
#exe {
|
2020-02-16 03:06:00 +00:00
|
|
|
|
if (!kernel_config->opts[CONFIG_NO_MP])
|
2020-02-15 20:01:48 +00:00
|
|
|
|
StreamPrint("\"MultiCore Start\\n\\n\";"
|
|
|
|
|
"Core0StartMP;"
|
|
|
|
|
"LBts(&sys_run_level,RLf_MP);");
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-16 03:06:00 +00:00
|
|
|
|
KbdMouseInit;
|
|
|
|
|
MouseInit;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
KbdInit;
|
2020-02-16 03:06:00 +00:00
|
|
|
|
Spawn(&MouseHardDriverInstall);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
|
|
|
|
|
"Loading Compiler\n";
|
|
|
|
|
Cd("/Compiler");
|
|
|
|
|
Load("Compiler",LDF_SILENT);
|
|
|
|
|
LBts(&sys_run_level,RLf_COMPILER);
|
|
|
|
|
|
2020-02-15 22:25:33 +00:00
|
|
|
|
DebugMode(OFF);
|
2020-02-16 00:20:04 +00:00
|
|
|
|
counts.time_stamp_freq_initial=TimeCal;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
Cd("/");
|
2020-02-16 04:57:03 +00:00
|
|
|
|
try ExeFile("StartOS"); //Continues $LK,"/StartOS.CC",A="FL:/StartOS.CC,1"$
|
2020-02-15 20:01:48 +00:00
|
|
|
|
catch {
|
|
|
|
|
Raw(ON);
|
|
|
|
|
Silent(OFF);
|
|
|
|
|
GetOutOfDollar;
|
|
|
|
|
PutExcept;
|
2020-02-15 22:25:33 +00:00
|
|
|
|
Debug;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 22:25:33 +00:00
|
|
|
|
LBts(&sys_run_level,RLf_ZENITH_SERVER);
|
2020-02-16 06:07:34 +00:00
|
|
|
|
ServerTaskCont; //Never to return
|
2020-02-15 20:01:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asm { ALIGN 16,OC_NOP
|
|
|
|
|
SYS_KERNEL_END::
|
|
|
|
|
#exe {
|
2020-02-16 08:00:07 +00:00
|
|
|
|
if (kernel_config->opts[CONFIG_DEBUG_DISTRO])
|
2020-02-15 20:01:48 +00:00
|
|
|
|
StreamPrint("DU8 0x%X-(SYS_KERNEL_END-SYS_KERNEL+"
|
|
|
|
|
"BOOT_RAM_BASE+sizeof(CBinFile)) DUP (0);"
|
2020-02-16 03:37:50 +00:00
|
|
|
|
"BINFILE \"%s\";",kernel_config->debug_distro_start,
|
|
|
|
|
kernel_config->debug_distro_file);
|
2020-02-15 20:01:48 +00:00
|
|
|
|
};
|
|
|
|
|
}
|