diff --git a/src/sys/include/ubixos/init.h b/src/sys/include/ubixos/init.h index 8ec31df..87c7526 100644 --- a/src/sys/include/ubixos/init.h +++ b/src/sys/include/ubixos/init.h @@ -58,8 +58,8 @@ pit_init, atkbd_init, time_init, - /*net_init,*/ - /*ne2k_init, */ + net_init, + ne2k_init, devfs_init, ubixfs_init, fdc_init, @@ -71,6 +71,15 @@ /*** $Log$ + Revision 1.23 2004/07/28 00:17:05 reddawg + Major: + Disconnected page 0x0 from the system... Unfortunately this broke many things + all of which have been fixed. This was good because nothing deferences NULL + any more. + + Things affected: + malloc,kmalloc,getfreepage,getfreevirtualpage,pagefault,fork,exec,ld,ld.so,exec,file + Revision 1.22 2004/07/24 23:04:44 reddawg Changes... mark let me know if you fault at pid 185 when you type stress diff --git a/src/sys/isa/ne2k.c b/src/sys/isa/ne2k.c index 8cb0cf5..a878556 100644 --- a/src/sys/isa/ne2k.c +++ b/src/sys/isa/ne2k.c @@ -45,6 +45,7 @@ static int dp_recv(struct device *); static struct nicBuffer *ne2kBuffer = 0x0; +static struct device *mDev = 0x0; asm( ".globl ne2kISR \n" @@ -64,51 +65,45 @@ ************************************************************************/ int ne2k_init() { - struct device *dev = (struct device *)kmalloc(sizeof(struct device)); - dev->ioAddr = 0x280; - dev->irq = 10; - + mDev = (struct device *)kmalloc(sizeof(struct device)); + mDev->ioAddr = 0x280; + mDev->irq = 10; setVector(&ne2kISR, mVec+10, dPresent + dInt + dDpl3); - outportByte(mPic, eoi); - outportByte(sPic, eoi); irqEnable(10); - outportByte(mPic, eoi); - outportByte(sPic, eoi); // kprintf("ne0 - irq: %i, ioAddr: 0x%X MAC: %X:%X:%X:%X:%X:%X\n",dev->irq,dev->ioAddr,dev->net->mac[0] & 0xFF,dev->net->mac[1] & 0xFF,dev->net->mac[2] & 0xFF,dev->net->mac[3] & 0xFF,dev->net->mac[4] & 0xFF,dev->net->mac[5] & 0xFF); - outportByte(dev->ioAddr + NE_CMD, 0x21); //stop mode - outportByte(dev->ioAddr + NE_DCR,0x29); // 0x29 data config reg - outportByte(dev->ioAddr + NE_RBCR0,0x00); // LOW byte count (remote) - outportByte(dev->ioAddr + NE_RBCR1,0x00); // HIGH byte count (remote) - outportByte(dev->ioAddr + NE_RCR,0x3C); // receive config reg - outportByte(dev->ioAddr + NE_TCR,0x02); // LOOP mode (temp) - outportByte(dev->ioAddr + NE_PSTART,startPage); // 0x26 PAGE start - outportByte(dev->ioAddr + NE_BNRY,startPage); // 0x26 BOUNDARY - outportByte(dev->ioAddr + NE_PSTOP,stopPage); // 0x40 PAGE stop - outportByte(dev->ioAddr + NE_ISR,0xFF); // interrupt status reg - outportByte(dev->ioAddr + NE_IMR,0x0B); - outportByte(dev->ioAddr + NE_CMD,0x61); // PAGE 1 regs + outportByte(mDev->ioAddr + NE_CMD, 0x21); //stop mode + outportByte(mDev->ioAddr + NE_DCR,0x29); // 0x29 data config reg + outportByte(mDev->ioAddr + NE_RBCR0,0x00); // LOW byte count (remote) + outportByte(mDev->ioAddr + NE_RBCR1,0x00); // HIGH byte count (remote) + outportByte(mDev->ioAddr + NE_RCR,0x3C); // receive config reg + outportByte(mDev->ioAddr + NE_TCR,0x02); // LOOP mode (temp) + outportByte(mDev->ioAddr + NE_PSTART,startPage); // 0x26 PAGE start + outportByte(mDev->ioAddr + NE_BNRY,startPage); // 0x26 BOUNDARY + outportByte(mDev->ioAddr + NE_PSTOP,stopPage); // 0x40 PAGE stop + outportByte(mDev->ioAddr + NE_ISR,0xFF); // interrupt status reg + outportByte(mDev->ioAddr + NE_IMR,0x0B); + outportByte(mDev->ioAddr + NE_CMD,0x61); // PAGE 1 regs - outportByte(dev->ioAddr + DP_MAR0, 0xFF); - outportByte(dev->ioAddr + DP_MAR1, 0xFF); - outportByte(dev->ioAddr + DP_MAR2, 0xFF); - outportByte(dev->ioAddr + DP_MAR3, 0xFF); - outportByte(dev->ioAddr + DP_MAR4, 0xFF); - outportByte(dev->ioAddr + DP_MAR5, 0xFF); - outportByte(dev->ioAddr + DP_MAR6, 0xFF); - outportByte(dev->ioAddr + DP_MAR7, 0xFF); - outportByte(dev->ioAddr + DP_CURR, startPage + 1); - outportByte(dev->ioAddr + NE_CMD, 0x20); - inportByte(dev->ioAddr + DP_CNTR0); /* reset counters by reading */ - inportByte(dev->ioAddr + DP_CNTR1); - inportByte(dev->ioAddr + DP_CNTR2); + outportByte(mDev->ioAddr + DP_MAR0, 0xFF); + outportByte(mDev->ioAddr + DP_MAR1, 0xFF); + outportByte(mDev->ioAddr + DP_MAR2, 0xFF); + outportByte(mDev->ioAddr + DP_MAR3, 0xFF); + outportByte(mDev->ioAddr + DP_MAR4, 0xFF); + outportByte(mDev->ioAddr + DP_MAR5, 0xFF); + outportByte(mDev->ioAddr + DP_MAR6, 0xFF); + outportByte(mDev->ioAddr + DP_MAR7, 0xFF); + outportByte(mDev->ioAddr + DP_CURR, startPage + 1); + outportByte(mDev->ioAddr + NE_CMD, 0x20); + inportByte(mDev->ioAddr + DP_CNTR0); /* reset counters by reading */ + inportByte(mDev->ioAddr + DP_CNTR1); + inportByte(mDev->ioAddr + DP_CNTR2); - outportByte(dev->ioAddr + NE_TCR, 0x00); + outportByte(mDev->ioAddr + NE_TCR, 0x00); - outportByte(dev->ioAddr + NE_CMD, 0x0); - outportByte(dev->ioAddr + NE_DCR, 0x29); + outportByte(mDev->ioAddr + NE_CMD, 0x0); + outportByte(mDev->ioAddr + NE_DCR, 0x29); - kfree(dev); kprintf("Initialized"); /* Return so we know everything went well */ return(0x0); @@ -198,32 +193,24 @@ void ne2kHandler() { uInt16 isr = 0x0; uInt16 status = 0x0; - struct device *dev = (struct device *)kmalloc(sizeof(struct device)); - dev->ioAddr = 0x280; - dev->irq = 10; - isr = inportByte(dev->ioAddr + NE_ISR); + asm("sti"); + + isr = inportByte(mDev->ioAddr + NE_ISR); + if ((isr & 0x02) == 0x02) { - outportByte(dev->ioAddr + NE_ISR, 0x0A); + outportByte(mDev->ioAddr + NE_ISR, 0x0A); status = inportByte(0x280 + NE_TPSR); - //kprintf("Pack Transmitted, Status: [0x%X]\n",status); } if ((isr & 0x01) == 0x01) { - //kprintf("Status: [0x%X]\n",inportByte(dev->ioAddr + NE_ISR)); - if (dp_recv(dev)) { + if (dp_recv(mDev)) { kprintf("Error Getting Packet\n"); } - outportByte(dev->ioAddr + NE_ISR, 0x05); + outportByte(mDev->ioAddr + NE_ISR, 0x05); } - /* - else { - kprintf("Word: [0x%X]\n",isr); - } - */ - outportByte(dev->ioAddr + NE_IMR,0x0); + outportByte(mDev->ioAddr + NE_IMR,0x0); + outportByte(mDev->ioAddr + NE_IMR,0x0B); outportByte(mPic, eoi); - outportByte(sPic, eoi); - outportByte(dev->ioAddr + NE_IMR,0x0B); - kfree(dev); + outportByte(sPic,eoi); return; } @@ -233,7 +220,7 @@ int packet_processed = 0x0, r; uInt16 eth_type; - uInt32 length = 0x0;//UBU + uInt32 length = 0x0; pageno = inportByte(dev->ioAddr + NE_BNRY) + 1; if (pageno == stopPage) pageno = startPage; @@ -341,7 +328,8 @@ struct nicBuffer *ne2kGetBuffer() { struct nicBuffer *tmpBuf = 0x0; tmpBuf = ne2kBuffer; - ne2kBuffer = ne2kBuffer->next; + if (ne2kBuffer != 0x0) + ne2kBuffer = ne2kBuffer->next; return(tmpBuf); } @@ -354,6 +342,9 @@ /*** $Log$ + Revision 1.15 2004/07/17 17:04:47 reddawg + ne2k: added assert hopefully it will help me solve this dma size 0 random error + Revision 1.14 2004/07/14 12:03:50 reddawg ne2k: ne2kInit to ne2k_init Changed Startup Routines diff --git a/src/sys/kernel/ubthread.c b/src/sys/kernel/ubthread.c index ef44f02..fadc2c4 100644 --- a/src/sys/kernel/ubthread.c +++ b/src/sys/kernel/ubthread.c @@ -80,7 +80,7 @@ int ubthread_mutex_lock(ubthread_mutex_t *mutex) { ubthread_mutex_t ubmutex = *mutex; if (ubmutex->locked == LOCKED) { - //kprintf("Mutex Already Lock By %x Trying To Be Relocked By %x\n",ubmutex->pid,_current->id); + kprintf("Mutex Already Lock By %x Trying To Be Relocked By %x\n",ubmutex->pid,_current->id); while (ubmutex->locked == LOCKED); } ubmutex->locked = LOCKED; @@ -129,6 +129,9 @@ /*** $Log$ + Revision 1.6 2004/06/15 12:24:07 reddawg + Cleaned Up + Revision 1.5 2004/05/26 03:13:37 reddawg Changing the way our mutex work diff --git a/src/sys/net/net/init.c b/src/sys/net/net/init.c index 4a46cb8..b0a3546 100644 --- a/src/sys/net/net/init.c +++ b/src/sys/net/net/init.c @@ -85,7 +85,7 @@ netif_add(&ipaddr, &netmask, &gw, loopif_init, tcpip_input); //udpecho_init(); - //shell_init(); + shell_init(); //bot_init(); kprintf("Application Started\n"); diff --git a/src/sys/net/net/shell.c b/src/sys/net/net/shell.c index f9dd39e..32e7ed6 100644 --- a/src/sys/net/net/shell.c +++ b/src/sys/net/net/shell.c @@ -67,38 +67,25 @@ uInt32 len; int i; char bufr[1500]; - - do { - if (buf != NULL) { - buf = netconn_recv(conn); - netbuf_copy(buf, buffer, 1024); + prompt(conn); + while (1) { + buf = netconn_recv(conn); + if (buf != 0x0) + netbuf_copy(buf,buffer,1024); len = netbuf_len(buf); netbuf_delete(buf); buffer[len-2] = '\0'; - kprintf("Buffer: [%s:%i]",buffer,len); - //sprintf(bufr,"Command: %s not found.\n",buffer); - sendstr("BLah\n",conn); - } - if (buf != NULL) { + kprintf("Buffer: [%s:%i]\n",buffer,len); + if (!strcmp(buffer,"quit")) { + netconn_close(conn); + break; + } prompt(conn); } - } while(buf != NULL); - kprintf("buf == NULL err %s\n", lwip_strerr(conn->err)); - close: - netconn_close(conn); - - for(i = 0; i < NCONNS; i++) { - if(conns[i] != NULL) { - netconn_delete(conns[i]); - } - conns[i] = NULL; - } } static void shell_thread(void *arg) { - struct netconn *conn, *newconn; - - char *str = (char *)kmalloc(64); + struct netconn *conn = 0x0, *newconn = 0x0; buffer = (char *)kmalloc(1024); @@ -108,8 +95,11 @@ while(1) { newconn = netconn_accept(conn); + kprintf("2\n"); shell_main(newconn); + kprintf("3\n"); netconn_delete(newconn); + kprintf("4\n"); } } diff --git a/src/sys/net/netif/ethernetif.c b/src/sys/net/netif/ethernetif.c index 91b6fa1..3c98fc2 100644 --- a/src/sys/net/netif/ethernetif.c +++ b/src/sys/net/netif/ethernetif.c @@ -349,7 +349,7 @@ while (1) { tmpBuf = ne2kGetBuffer(); - if (tmpBuf->length > 0x0) { + if (tmpBuf && tmpBuf->length > 0x0) { ethernetif_input(netif); } } diff --git a/src/sys/sys/idt.c b/src/sys/sys/idt.c index 7d94ceb..f44fae5 100644 --- a/src/sys/sys/idt.c +++ b/src/sys/sys/idt.c @@ -91,8 +91,8 @@ setVector(_int5, 5, dPresent + dInt + dDpl3); setVector(_int6, 6, dPresent + dInt + dDpl3); setVector(_int7,7,dPresent + dInt + dDpl3); - //setVector(_int8,8,dPresent + dInt + dDpl3); - setTaskVector(8,dPresent + dTask + dDpl3, 0x38); + setVector(_int8,8,dPresent + dInt + dDpl3); + //setTaskVector(8,dPresent + dTask + dDpl3, 0x38); setVector(_int9, 9, dPresent + dInt + dDpl3); setVector(_int10, 10, dPresent + dInt + dDpl3); setVector(_int11, 11, dPresent + dInt + dDpl3); @@ -256,32 +256,7 @@ uInt8 *ip = 0x0; uInt16 *stack = 0x0, *ivt = 0x0; uInt32 *stack32 = 0x0; - uInt32 memAddr = 0x0; bool isOperand32 = FALSE, isAddress32 = FALSE; - - - /* UBU */ - uInt32 *pageDir = 0x0,*pageTable = 0x0; - uInt32 i = 0, pageTableIndex = 0,pageDirectoryIndex = 0; - - asm( - "movl %%cr2,%0\n" - : "=g" (memAddr) - ); - - pageDir = parentPageDirAddr; - //Calculate The Page Directory Index - pageDirectoryIndex = (memAddr >> 22); - - //Calculate The Page Table Index - pageTableIndex = ((memAddr >> 12) & 0x3FF); - - pageTable = (uInt32 *)(tablesBaseAddress + (0x1000 * pageDirectoryIndex)); - asm("cli"); - - kprintf("Page Table Addr: [0x%X]\n",pageDir[pageDirectoryIndex]); - kpanic("gpf [%i][0x%X][0x%X][0x%X][0x%X]\n",_current->id,_current->tss.eip,_current->tss.esp,_current->tss.esp0,memAddr); - endTask(_current->id); irqDisable(0x0); @@ -455,6 +430,12 @@ /*** $Log$ + Revision 1.23 2004/07/28 15:05:43 reddawg + Major: + Pages now have strict security enforcement. + Many null dereferences have been resolved. + When apps loaded permissions set for pages rw and ro + Revision 1.22 2004/07/28 00:17:05 reddawg Major: Disconnected page 0x0 from the system... Unfortunately this broke many things diff --git a/src/sys/vmm/page_fault.S b/src/sys/vmm/page_fault.S index 24ccddf..0e59503 100644 --- a/src/sys/vmm/page_fault.S +++ b/src/sys/vmm/page_fault.S @@ -35,18 +35,22 @@ movl 4(%esp),%eax pushl %ecx pushl %edx + /* push %ds push %es push %fs + */ push %eax movl %cr2,%eax pushl %eax - sti + sti call vmm_pageFault addl $0x8,%esp + /* pop %fs pop %es - pop %ds + pop %ds + */ popl %edx popl %ecx popl %eax @@ -55,6 +59,9 @@ /*** $Log$ + Revision 1.2 2004/07/26 19:15:49 reddawg + test code, fixes and the like + Revision 1.1 2004/07/24 23:13:21 reddawg Oh yeah try this one