diff --git a/TempleOSCD/0000Boot/0000Kernel.BIN.C b/TempleOSCD/0000Boot/0000Kernel.BIN.C index 5e69475..5601683 100644 Binary files a/TempleOSCD/0000Boot/0000Kernel.BIN.C and b/TempleOSCD/0000Boot/0000Kernel.BIN.C differ diff --git a/TempleOSCD/Adam/ADefine.HC b/TempleOSCD/Adam/ADefine.HC index e8d708a..bf6bb98 100644 --- a/TempleOSCD/Adam/ADefine.HC +++ b/TempleOSCD/Adam/ADefine.HC @@ -11,7 +11,7 @@ U0 LoadDocDefines() //This is cut and replaced when I generate a distro. //See $LK,"DD_TEMPLEOS_LOC",A="FF:::/Demo/AcctExample/TOS/TOSDistro.HC,DD_TEMPLEOS_LOC"$. $TR-C,"LineRep"$ - $ID,4$DefinePrint("DD_TEMPLEOS_LOC","119,749"); + $ID,4$DefinePrint("DD_TEMPLEOS_LOC","119,767"); DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","81,933"); $ID,-4$ DefinePrint("DD_KERNEL","%08X",bfh); diff --git a/TempleOSCD/Compiler/Compiler.BIN b/TempleOSCD/Compiler/Compiler.BIN index e879778..49d1311 100644 Binary files a/TempleOSCD/Compiler/Compiler.BIN and b/TempleOSCD/Compiler/Compiler.BIN differ diff --git a/TempleOSCD/Compiler/CompilerB.HH b/TempleOSCD/Compiler/CompilerB.HH index 67409e3..989e1f4 100644 --- a/TempleOSCD/Compiler/CompilerB.HH +++ b/TempleOSCD/Compiler/CompilerB.HH @@ -21,6 +21,7 @@ extern U0 StreamDir(); public extern I64 StreamExePrint(U8 *fmt,...); public extern U0 StreamPrint(U8 *fmt,...); public extern Bool Trace(Bool val=ON); + #help_index "Compiler/Lex" #help_file "::/Doc/Lex" extern U0 ClassMemberLstDel(CHashClass *c); diff --git a/TempleOSCD/Demo/AcctExample/Registry.HC b/TempleOSCD/Demo/AcctExample/Registry.HC index dfbc0b3..6f11399 100644 --- a/TempleOSCD/Demo/AcctExample/Registry.HC +++ b/TempleOSCD/Demo/AcctExample/Registry.HC @@ -53,16 +53,16 @@ $ID,2$I64 best_score=175; $ID,-2$$TR,"OSTestSuite"$ $ID,2$progress1_tf=0.000;progress2_tf=0.000; progress3_tf=0.000;progress4_tf=228.734; -$ID,-2$$TR,"Titanium"$ -$ID,2$I64 best_score=16469; $ID,-2$$TR,"XCaliber"$ $ID,2$I64 best_score=90; I64 msg_flags=2; $ID,-2$$TR,"Talons"$ $ID,2$F64 best_score=9999.0000; +$ID,-2$$TR,"Titanium"$ +$ID,2$I64 best_score=16469; $ID,-2$$TR,"TOSRegen"$ $ID,2$progress1_tf=0.000;progress2_tf=0.000; -progress3_tf=0.000;progress4_tf=200.498; +progress3_tf=0.000;progress4_tf=199.386; $ID,-2$$ID,-2$$TR,"Once"$ $ID,2$$TR,"Adam"$ $ID,2$$ID,-2$$TR,"User"$ diff --git a/TempleOSCD/Demo/AcctExample/TOS/TOSDistro.HC b/TempleOSCD/Demo/AcctExample/TOS/TOSDistro.HC index 7310056..d09e499 100644 --- a/TempleOSCD/Demo/AcctExample/TOS/TOSDistro.HC +++ b/TempleOSCD/Demo/AcctExample/TOS/TOSDistro.HC @@ -570,6 +570,8 @@ public U0 TOSPreRegen() Copy("D:/Home/Sup1/Sup1Blog/Bookmarks.html","C:/Home/Sup1/Sup1Blog"); Del("C:/Home/Sup1/Sup1Bin/*"); Copy("D:/Home/Sup1/Sup1Bin/*","C:/Home/Sup1/Sup1Bin"); + Copy("D:/Home/Sup1/Sup1CodeScraps/Comm/TOSSocket*", + "C:/Home/Sup1/Sup1CodeScraps/Comm"); Copy("D:/Home/Sup1/Sup1Bin/God*","C:/Linux"); } diff --git a/TempleOSCD/Doc/ChgLog.DD b/TempleOSCD/Doc/ChgLog.DD index 8d305e1..2ac5f0d 100644 --- a/TempleOSCD/Doc/ChgLog.DD +++ b/TempleOSCD/Doc/ChgLog.DD @@ -2,6 +2,8 @@ $WW,1$$FG,5$$TX+CX,"Change Log"$$FG$ Use $LK,"R",A="MN:R"$() to rename if I change a label. +$IV,1$----01/22/17 17:18:21----$IV,0$ + $IV,1$----01/22/17 06:08:00----$IV,0$ * $BK,1$TempleOS version 5.02 Released$BK,0$ * Changed polling of $LK,"KbdMsHndlr",A="MN:KbdMsHndlr"$() in $LK,"WinMgrSleep",A="MN:WinMgrSleep"$(), increased fifos. diff --git a/TempleOSCD/Doc/Comm.HC b/TempleOSCD/Doc/Comm.HC index e33126b..e37e045 100644 --- a/TempleOSCD/Doc/Comm.HC +++ b/TempleOSCD/Doc/Comm.HC @@ -5,11 +5,6 @@ it in your start-up scripts. #help_index "Comm" -#define COM1_BASE 0x3F8 -#define COM2_BASE 0x2F8 -#define COM3_BASE 0x3E8 -#define COM4_BASE 0x2E8 - #define UART_THR 0 #define UART_RDR 0 #define UART_BRDL 0 @@ -21,96 +16,117 @@ it in your start-up scripts. #define UART_LSR 5 #define UART_MSR 6 -I64 comm_base[5]={0,0x3F8,0x2F8,0x3E8,0x2E8}; +#define COMf_ENABLED 0 +class CComm +{ + I64 base, + flags; + CFifoU8 *RX_fifo; + CFifoU8 *TX_fifo; +} comm_ports[5]; -CFifoU8 *comm_fifos[5]={NULL,NULL,NULL,NULL,NULL}; +U0 CommHndlr(I64 port) +{ + CComm *c=&comm_ports[port]; + I64 b=0,stat; + if (Bt(&c->flags,COMf_ENABLED)) { + stat=InU8(c->base+UART_IIR); + if (stat & 4) //RX + FifoU8Ins(c->RX_fifo,InU8(c->base+UART_RDR)); + if (stat & 2) { //TX + if (FifoU8Rem(c->TX_fifo,&b)) + OutU8(c->base+UART_THR,b); + else + OutU8(c->base+UART_IER,1); //RX but no THR empty + } + } +} interrupt U0 IRQComm3() { - I64 base=comm_base[2]; - if (comm_fifos[2] && (InU8(base+UART_IIR) & 0xFE)==4) //RX IRQ - FifoU8Ins(comm_fifos[2],InU8(base+UART_RDR)); - - base=comm_base[4]; - if (comm_fifos[4] && (InU8(base+UART_IIR) & 0xFE)==4) //RX IRQ - FifoU8Ins(comm_fifos[4],InU8(base+UART_RDR)); + CommHndlr(2); + CommHndlr(4); OutU8(0x20,0x20); } interrupt U0 IRQComm4() { - I64 base=comm_base[1]; - if (comm_fifos[1] && (InU8(base+UART_IIR) & 0xFE)==4) //RX IRQ - FifoU8Ins(comm_fifos[1],InU8(base+UART_RDR)); - - base=comm_base[3]; - if (comm_fifos[3] && (InU8(base+UART_IIR) & 0xFE)==4) //RX IRQ - FifoU8Ins(comm_fifos[3],InU8(base+UART_RDR)); + CommHndlr(1); + CommHndlr(3); OutU8(0x20,0x20); } -IntEntrySet(0x23,&IRQComm3); -IntEntrySet(0x24,&IRQComm4); - -public U0 CommInit8n1(I64 port,I64 baud) +U0 CommInit() { - I64 base=comm_base[port]; + MemSet(&comm_ports,0,sizeof(comm_ports)); + comm_ports[1].base=0x3F8; + comm_ports[2].base=0x2F8; + comm_ports[3].base=0x3E8; + comm_ports[4].base=0x2E8; + IntEntrySet(0x23,&IRQComm3); + IntEntrySet(0x24,&IRQComm4); +} +CommInit; + +public CComm *CommInit8n1(I64 port,I64 baud) +{ + CComm *c=&comm_ports[port]; PUSHFD CLI - if (comm_fifos[port]) - FifoU8Del(comm_fifos[port]); - comm_fifos[port]=FifoU8New(256); - OutU8(base+UART_LCR,0); //Set for IER - OutU8(base+UART_IER,0); //Disable all IRQ - OutU8(base+UART_LCR,0x80); //Enable baud rate control - OutU8(base+UART_BRDL,(0x180/(baud/300)) & 0xFF); //LSB - OutU8(base+UART_BRDH,(0x180/(baud/300)) / 256); //MSB - OutU8(base+UART_LCR,3); // 8-none-1 + if (LBts(&c->flags,COMf_ENABLED)) { + FifoU8Del(c->RX_fifo); + FifoU8Del(c->TX_fifo); + } + c->RX_fifo=FifoU8New(256); + c->TX_fifo=FifoU8New(256); + OutU8(c->base+UART_LCR,0); //Set for IER + OutU8(c->base+UART_IER,0); //Disable all IRQ + OutU8(c->base+UART_LCR,0x80); //Enable baud rate control + OutU8(c->base+UART_BRDL,(0x180/(baud/300)) & 0xFF); //LSB + OutU8(c->base+UART_BRDH,(0x180/(baud/300)) / 256); //MSB + OutU8(c->base+UART_LCR,3); //8-none-1 - InU8(base+UART_RDR); //read garbage - InU8(base+UART_LSR); + InU8(c->base+UART_RDR); //read garbage + InU8(c->base+UART_LSR); - OutU8(base+UART_MCR,4); - OutU8(base+UART_IER,0); //Disable all IRQ - OutU8(base+UART_MCR,0xA); //out2 and rts - OutU8(0x21,InU8(0x21) & (0xFF-0x18)); //Enable 8259 IRQ 3 & 4 - OutU8(base+UART_IER,1); //Enable RX IRQ + OutU8(c->base+UART_MCR,4); + OutU8(c->base+UART_IER,0); //Disable all IRQ + OutU8(c->base+UART_MCR,0xA); //out2 and rts + OutU8(0x21,InU8(0x21) & (0xFF-0x18)); //Enable 8259 IRQ 3 & 4 + OutU8(c->base+UART_IER,1); //RX but no THR empty POPFD + + return c; } -public U0 CommBusyPutChar(I64 port,U8 b) +public U0 CommPutChar(I64 port,U8 b) { - I64 base=comm_base[port]; - while (!(InU8(base+UART_LSR) & 0x20)) - Yield; - OutU8(base+UART_THR,b); - while (!(InU8(base+UART_LSR) & 0x20)) - Yield; + CComm *c=&comm_ports[port]; + PUSHFD + CLI + FifoU8Ins(c->TX_fifo,b); + OutU8(c->base+UART_IER,3); //RX and THR empty + POPFD + Sleep(10); //!!! Remove this line!!! Linux echo_socket is too slow. } -public U0 CommBusyPutS(I64 port,U8 *st) +U0 CommPutS(I64 port,U8 *st) { - I64 b,base=comm_base[port]; - while (b=*(st++)) { - while (!(InU8(base+UART_LSR) & 0x20)) - Yield; - OutU8(base+UART_THR,b); - } - while (!(InU8(base+UART_LSR) & 0x20)) - Yield; + I64 b; + while (b=*st++) + CommPutChar(port,b); } -public U0 CommBusyWriteBlk(I64 port,U8 *buf,I64 count) +public U0 CommPutBlk(I64 port,U8 *buf,I64 cnt) { - I64 base=comm_base[port]; - while (count--) { - while (!(InU8(base+UART_LSR) & 0x20)) - Yield; - OutU8(base+UART_THR,*(buf++)); - } - while (!(InU8(base+UART_LSR) & 0x20)) - Yield; + while (cnt--) + CommPutChar(port,*buf++); } -#help_index "" +public U0 CommPrint(I64 port,U8 *fmt,...) +{ + U8 *buf=StrPrintJoin(NULL,fmt,argc,argv); + CommPutS(port,buf); + Free(buf); +} diff --git a/TempleOSCD/Kernel/KernelC.HH b/TempleOSCD/Kernel/KernelC.HH index d8244fd..2a660ae 100644 --- a/TempleOSCD/Kernel/KernelC.HH +++ b/TempleOSCD/Kernel/KernelC.HH @@ -38,7 +38,6 @@ char_bmp_zero_tab_cr_nl_cursor_dollar[16], char_bmp_macro[16], char_bmp_printable[16], char_bmp_displayable[16], char_bmp_safe_dollar[16], char_bmp_filename[16], char_bmp_non_eol[16]; - #help_index "Char/Conversion" public extern U8 *Char2KeyName(I64 ch,Bool include_ctrl=TRUE); public extern I64 Char2ScanCode(I64 ch,I64 sc_flags=0); @@ -761,4 +760,5 @@ public extern F64 tS(); //From SysTimerFreq. #help_index "Windows" public extern Bool WinInside(I64 x,I64 y,CTask *task=NULL,I64 border=0); + #help_index ""