diff --git a/src/sys/i386/trap.c b/src/sys/i386/trap.c index f3a3913..048e82d 100644 --- a/src/sys/i386/trap.c +++ b/src/sys/i386/trap.c @@ -44,7 +44,7 @@ if (SEL_GET_PL(frame->tf_cs) == SEL_PL_USER || (frame->tf_eflags & PSL_VM)) kpanic( "INT OFF! USER" ); else - kpanic( "INT OFF! KERN" ); + kpanic( "INT OFF! KERN[0x%X]", trap_code ); } kprintf("trap_code: %i(0x%X), EIP: 0x%X\n", frame->tf_trapno, frame->tf_trapno, frame->tf_eip); diff --git a/src/sys/include/pci/lnc.h b/src/sys/include/pci/lnc.h index 0d63c1e..a762cb9 100644 --- a/src/sys/include/pci/lnc.h +++ b/src/sys/include/pci/lnc.h @@ -89,28 +89,28 @@ }; struct arpcom { - //struct ifnet ac_if; /* network-visible interface */ - uint8_t ac_enaddr[6]; /* ethernet hardware address */ - int ac_multicnt; /* length of ac_multiaddrs list */ - void *ac_netgraph; /* ng_ether(4) netgraph node info */ + //struct ifnet ac_if; /* network-visible interface */ + uint8_t ac_enaddr[6]; /* ethernet hardware address */ + int ac_multicnt; /* length of ac_multiaddrs list */ + void *ac_netgraph; /* ng_ether(4) netgraph node info */ }; struct nicInfo { - int ident; /* Type of card */ - int ic; /* Type of ic, Am7990, Am79C960 etc. */ - int memMode; - int iobase; - int mode; /* Mode setting at initialization */ + int ident; /* Type of card */ + int ic; /* Type of ic, Am7990, Am79C960 etc. */ + int memMode; + int iobase; + int mode; /* Mode setting at initialization */ }; struct initBlock16 { - uint16_t mode; // Mode register - uint8_t padr[6]; // Ethernet address - uint8_t ladrf[8]; // Logical address filter (multicast) - uint16_t rdra; // Low order pointer to receive ring - uint16_t rlen; // High order pointer and no. rings - uint16_t tdra; // Low order pointer to transmit ring - uint16_t tlen; // High order pointer and no rings + uint16_t mode; // Mode register + uint8_t padr[6]; // Ethernet address + uint8_t ladrf[8]; // Logical address filter (multicast) + uint16_t rdra; // Low order pointer to receive ring + uint16_t rlen; // High order pointer and no. rings + uint16_t tdra; // Low order pointer to transmit ring + uint16_t tlen; // High order pointer and no rings }; struct initBlock32 { @@ -136,7 +136,7 @@ unsigned int ioAddr; int nrdre; int ntdre; - const int bufferSize = 1548; + int bufferSize; int txPtr; }; diff --git a/src/sys/include/pci/pci.h b/src/sys/include/pci/pci.h index 3cbb188..a75e317 100644 --- a/src/sys/include/pci/pci.h +++ b/src/sys/include/pci/pci.h @@ -34,44 +34,59 @@ struct pciConfig { - uInt16 vendorId; - uInt16 deviceId; + uint16_t vendorId; + uint16_t deviceId; - uInt16 command; - uInt16 status; + uint16_t command; + uint16_t status; - uInt8 revisionId; - uInt8 interface; - uInt8 subClass; - uInt8 baseClass; + uint8_t revisionId; + uint8_t interface; + uint8_t subClass; + uint8_t baseClass; - uInt8 cacheLineSize; - uInt8 latencyTimer; - uInt8 headerType; - uInt8 bist; + uint8_t cacheLineSize; + uint8_t latencyTimer; + uint8_t headerType; + uint8_t bist; + + uint32_t bar[6]; + + uint32_t cisPointer; + uint16_t subsysVendorID; + uint16_t subsystemID; + uint32_t epromAddr; + uint16_t capabilites; + uint16_t res1; + uint32_t res2; + uint8_t intLine; + uint8_t intPin; + uint8_t minGrant; + uint8_t maxLatency; /* device info */ - uInt8 bus; - uInt8 dev; - uInt8 func; - uInt8 irq; + //uint8_t bus; + //uint8_t dev; + //uint8_t func; + //uint8_t irq; + //uint8_t irqLine; /* base registers */ - uInt32 base[6]; - uInt32 size[6]; + //uInt32 base[6]; + //uInt32 size[6]; - uInt16 subsysVendor; - uInt16 subsys; + //uint16_t subsysVendor; + //uint16_t subsys; }; struct confadd { - uInt8 reg:8; - uInt8 func:3; - uInt8 dev:5; - uInt8 bus:8; - uInt8 rsvd:7; - uInt8 enable:1; + uint8_t reg:8; + uint8_t func:3; + uint8_t dev:5; + uint8_t bus:8; + uint8_t rsvd:7; + uint8_t enable:1; }; #define countof(a) (sizeof(a) / sizeof(a[0])) diff --git a/src/sys/include/ubixos/init.h b/src/sys/include/ubixos/init.h index 3cc2562..6c220a7 100644 --- a/src/sys/include/ubixos/init.h +++ b/src/sys/include/ubixos/init.h @@ -56,11 +56,8 @@ typedef int (*intFunctionPTR)( void ); intFunctionPTR init_tasks[] = { vmm_init, static_constructors, i8259_init, idt_init, vitals_init, sysctl_init, vfs_init, sched_init, pit_init, atkbd_init, time_init, -net_init, - devfs_init, - pci_init, - initLNC, - tty_init, ufs_init, initHardDisk, }; + pci_init, devfs_init, tty_init, ufs_init, initHardDisk, initLNC, net_init }; + //ne2k_init, //ubixfs_init, //fdc_init, diff --git a/src/sys/init/main.c b/src/sys/init/main.c index bdecda4..baca89a 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -111,6 +111,8 @@ if (init_tasks[i]() != 0x0) kpanic("Error: Initializing System Task[%i].\n", i); } + irqEnable(0x0); +while(1); /* New Root Mount Point */ //Old 2 new 10 diff --git a/src/sys/isa/Makefile b/src/sys/isa/Makefile index c429e79..83f6b5c 100644 --- a/src/sys/isa/Makefile +++ b/src/sys/isa/Makefile @@ -6,7 +6,8 @@ include ../Makefile.incl # Objects -OBJS = mouse.o atkbd.o fdc.o 8259.o pit.o ne2k.o +OBJS = mouse.o atkbd.o fdc.o 8259.o pit.o +# ne2k.o all: $(OBJS) diff --git a/src/sys/net/api/api_lib.c b/src/sys/net/api/api_lib.c index 1117c5c..6906c24 100644 --- a/src/sys/net/api/api_lib.c +++ b/src/sys/net/api/api_lib.c @@ -375,7 +375,7 @@ msg->msg.conn = conn; msg->msg.msg.bc.ipaddr = addr; msg->msg.msg.bc.port = port; - kprintf("1"); + kprintf("api1"); api_msg_post(msg); kprintf("2: [0x%X]",conn->mbox); sys_mbox_fetch(conn->mbox, NULL); diff --git a/src/sys/net/net/shell.c b/src/sys/net/net/shell.c index 3326596..95dd489 100644 --- a/src/sys/net/net/shell.c +++ b/src/sys/net/net/shell.c @@ -101,7 +101,7 @@ netconn_listen(conn); while(1) { - kprintf("1"); + kprintf("shell1"); newconn = netconn_accept(conn); kprintf("2"); shell_main(newconn); diff --git a/src/sys/net/netif/ethernetif.c b/src/sys/net/netif/ethernetif.c index 1d3969f..8f9a30f 100644 --- a/src/sys/net/netif/ethernetif.c +++ b/src/sys/net/netif/ethernetif.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "net/debug.h" @@ -83,20 +84,20 @@ ethernetif = netif->state; dev = (struct device *)kmalloc(sizeof(struct device)); - dev->ioAddr = 0x280; - dev->irq = 0x10; + dev->ioAddr = 0xD000; + dev->irq = 0x9; /* Obtain MAC address from network interface. */ - ethernetif->ethaddr->addr[0] = 0x00; + ethernetif->ethaddr->addr[0] = 0x08; ethernetif->ethaddr->addr[1] = 0x00; - ethernetif->ethaddr->addr[2] = 0xC0; - ethernetif->ethaddr->addr[3] = 0x97; - ethernetif->ethaddr->addr[4] = 0xC6; - ethernetif->ethaddr->addr[5] = 0x93; + ethernetif->ethaddr->addr[2] = 0x27; + ethernetif->ethaddr->addr[3] = 0x73; + ethernetif->ethaddr->addr[4] = 0xC1; + ethernetif->ethaddr->addr[5] = 0xB6; /* Do whatever else is needed to initialize interface. */ - kprintf("NETIF: [0x%X:0x%X]\n",netif,ethernetif_thread); - sys_thread_new(ethernetif_thread, netif); + kprintf("NETIF: [0x%X:0x%X]MrOlsen NOT STARTED THREAD\n",netif,ethernetif_thread); + //sys_thread_new(ethernetif_thread, netif); } /*-----------------------------------------------------------------------------------*/ @@ -124,7 +125,8 @@ bcopy(q->payload, bufptr, q->len); bufptr += q->len; } - PCtoNIC(dev,buf,p->tot_len); + //MrOlsen 2017PCtoNIC(dev,buf,p->tot_len); + lnc_sendPacket(lnc,buf,p->tot_len,0x0); //kprintf("Sending Data[%i]\n",p->tot_len); return ERR_OK; } @@ -346,6 +348,7 @@ struct netif *netif = 0x0; netif = arg; + /* MrOlsen 2017-12-16 while (1) { tmpBuf = ne2kGetBuffer(); @@ -354,4 +357,5 @@ } } ne2kFreeBuffer(tmpBuf); +*/ } diff --git a/src/sys/pci/lnc.c b/src/sys/pci/lnc.c index 9377188..ddbfba6 100644 --- a/src/sys/pci/lnc.c +++ b/src/sys/pci/lnc.c @@ -86,12 +86,14 @@ char data[64] = "abcDEFghiJKLmnoPQRstuVWXyz"; lnc = kmalloc(sizeof(struct lncInfo)); + memset(lnc, 0x0, sizeof(struct lncInfo)); + lnc->bufferSize = 1548; lnc->ioAddr = 0xD000; lnc->nic.ic = lnc_probe(lnc); - kprintf("ID: %i\n", lnc->nic.ic); + //kprintf("ID: %i\n", lnc->nic.ic); if ((lnc->nic.ic > 0) && (lnc->nic.ic >= PCnet_32)) { lnc->nic.ident = NE2100; @@ -127,7 +129,7 @@ iW = lnc_readBCR32(lnc, 0x2); iW |= 0x2; - lnc_writeBCR32(lnc, 2, iW); + lnc_writeBCR32(lnc, 0x2, iW); lnc->init.mode = 0x0; @@ -140,11 +142,13 @@ lnc->init.rdra = (uint32_t) vmm_getRealAddr(lnc->rxRing); lnc->init.rlen = 3 << 4; + //kprintf("Virt Addr: 0x%X, Real Addr: 0x%X", lnc->rxRing, vmm_getRealAddr(lnc->rxRing)); lnc->init.tdra = (uint32_t) vmm_getRealAddr(lnc->txRing); lnc->init.tlen = 3 << 4; + //kprintf("Virt Addr: 0x%X, Real Addr: 0x%X", lnc->txRing, vmm_getRealAddr(lnc->txRing)); - kprintf("Virt Addr: 0x%X, Real Addr: 0x%X", &lnc->init, vmm_getRealAddr(&lnc->init)); + //kprintf("Virt Addr: 0x%X, Real Addr: 0x%X", &lnc->init, vmm_getRealAddr(&lnc->init)); iW = vmm_getRealAddr(&lnc->init); @@ -160,8 +164,8 @@ if (lnc_readCSR32(lnc, CSR0) & IDON) { setVector(&lnc_isr, mVec + 0x9, (dInt + dPresent + dDpl0)); - irqEnable(0x9); lnc_writeCSR32(lnc, CSR0, STRT | INEA); + irqEnable(0x9); /* * sc->arpcom.ac_if.if_flags |= IFF_RUNNING; * sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; @@ -173,14 +177,14 @@ return (-1); } + /* kprintf("SENDING PACKET"); while (1) { iW = lnc_sendPacket(lnc, &data, strlen(data), 0x0); - if (iW) - kprintf("Sent %i Bytes", iW); - else - kprintf("Unable To Send %i Bytes", iW); + if (!iW) + kprintf("Sending Failed"); } + */ return (0); } @@ -191,7 +195,7 @@ int type = 0x0; if ((type = lanceProbe(lnc))) { - kprintf("Type: [0x%X]", type); + //kprintf("Type: [0x%X]", type); chipId = lnc_readCSR(lnc, CSR89); chipId <<= 16; chipId |= lnc_readCSR(lnc, CSR88); @@ -249,7 +253,9 @@ } void lncInt() { + while (1) { kprintf("Finished!!!\n"); + } outportByte(0x20, 0x20); return; uInt16 csr0 = 0x0; @@ -310,12 +316,11 @@ int lncAttach(struct lncInfo *lnc, int unit) { int i = 0; uint32_t lncSize = 0x0; - char *tmpBuffer = 0x0; uint16_t bcnt = 0x0; /* Initialize rxRing */ lncSize = (NDESC(lnc->nrdre) * sizeof(struct hostRingEntry)); - kprintf("rxRing Size: [%i]", lncSize); + //kprintf("rxRing Size: [%i]", lncSize); lnc->rxRing = kmalloc(lncSize); if (!lnc->rxRing) { @@ -327,7 +332,7 @@ /* Initialize rxBuffer */ lncSize = (NDESC(lnc->nrdre) * lnc->bufferSize); - kprintf("rxBuffer Size: [%i]\n", lncSize); + //kprintf("rxBuffer Size: [%i]\n", lncSize); lnc->rxBuffer = kmalloc(lncSize); if (!lnc->rxBuffer) { kprintf("lnc%d: Couldn't allocate memory for rXBuffer\n", unit); @@ -337,16 +342,18 @@ /* Setup the RX Ring */ for (i = 0; i < NDESC(lnc->nrdre); i++) { - lnc->rxRing->addr = (uint32_t) vmm_getRealAddr((uint32_t) lnc->rxRing + (i * lnc->bufferSize)); + lnc->rxRing[i].addr = (uint32_t) vmm_getRealAddr((uint32_t) lnc->rxRing + (i * lnc->bufferSize)); bcnt = (uint16_t) (-lnc->bufferSize); bcnt &= 0x0FFF; bcnt |= 0xF000; - lnc->rxRing->bcnt = bcnt; +//kprintf("rxR[%i].addr = 0x%X, BCNT 0x%X", i, lnc->rxRing[i].addr,bcnt); + lnc->rxRing[i].bcnt = bcnt; + lnc->rxRing[i].md[1] = 0x80; } /* Initialize txRing */ lncSize = (NDESC(lnc->ntdre) * sizeof(struct hostRingEntry)); - kprintf("txRing Size: [%i]", lncSize); + //kprintf("txRing Size: [%i]", lncSize); lnc->txRing = kmalloc(lncSize); if (!lnc->txRing) { @@ -358,7 +365,7 @@ /* Initialize txBuffer */ lncSize = (NDESC(lnc->ntdre) * lnc->bufferSize); - kprintf("txBuffer Size: [%i]\n", lncSize); + //kprintf("txBuffer Size: [%i]\n", lncSize); lnc->txBuffer = kmalloc(lncSize); if (!lnc->txBuffer) { kprintf("lnc%d: Couldn't allocate memory for txBuffer\n", unit); @@ -368,12 +375,12 @@ /* Setup the TX Ring */ for (i = 0; i < NDESC(lnc->ntdre); i++) { - lnc->txRing->addr = (uint32_t) vmm_getRealAddr((uint32_t) lnc->txRing + (i * lnc->bufferSize)); + lnc->txRing[i].addr = (uint32_t) vmm_getRealAddr((uint32_t) lnc->txRing + (i * lnc->bufferSize)); bcnt = (uint16_t) (-lnc->bufferSize); bcnt &= 0x0FFF; bcnt |= 0xF000; - lnc->txRing->bcnt = bcnt; - lnc->txRing->md[0] = 0x80; + //kprintf("txR[%i].addr = 0x%X, BCNT 0x%X", i, lnc->txRing[i].addr,bcnt); + lnc->txRing[i].bcnt = bcnt; } /* MrOlsen 2017-12-16 @@ -422,7 +429,7 @@ } int lnc_driverOwns(struct lncInfo *lnc) { - return (lnc->txRing[lnc->txPtr]->md[0] & 0x80) == 0; + return (lnc->txRing[lnc->txPtr].md[1] & 0x80) == 0; } int lnc_nextTxPtr(struct lncInfo *lnc) { @@ -432,27 +439,29 @@ ret = 0; } - return ret; + lnc->txPtr = ret; + + return(0); } int lnc_sendPacket(struct lncInfo *lnc, void *packet, size_t len, uint8_t *dest) { if (!lnc_driverOwns(lnc)) return (0); - memcpy((void *) (lnc->rxBuffer + (lnc->txPtr * lnc->bufferSize)), packet, len); + memcpy((void *) (lnc->txBuffer + (lnc->txPtr * lnc->bufferSize)), packet, len); - lnc->txRing[lnc->txPtr]->md[0] |= 0x2; - lnc->txRing[lnc->txPtr]->md[0] |= 0x1; + lnc->txRing[lnc->txPtr].md[1] |= 0x2; + lnc->txRing[lnc->txPtr].md[1] |= 0x1; //tdes[(tx_ptr * 16) + 7] |= 0x2; //tdes[(tx_ptr * 16) + 7] |= 0x1; - uInt16 bcnt = (uint16_t) (-len); + uint16_t bcnt = (uint16_t) (-len); bcnt &= 0xFFF; bcnt |= 0xF000; - lnc->rxRing[lnc->txPtr]->bcnt = bcnt; + lnc->txRing[lnc->txPtr].bcnt = bcnt; //*(uint16_t *) &tdes[tx_ptr * 16 + 4] = bcnt; - lnc->txRing[lnc->txPtr]->md[0] |= 0x80; + lnc->txRing[lnc->txPtr].md[1] |= 0x80; //tdes[tx_ptr * 16 + 7] |= 0x80; diff --git a/src/sys/pci/pci.c b/src/sys/pci/pci.c index 16861d9..0b6821b 100644 --- a/src/sys/pci/pci.c +++ b/src/sys/pci/pci.c @@ -285,6 +285,8 @@ } v = pciRead(bus,dev,func,0x3c,1); cfg->irq = (v == 0xff ? 0 : v); + v = pciRead(bus,dev,func,0x40,1); + cfg->irqLine = (v == 0xff ? 0 : v); break; case 1: kprintf(" * PCI <-> PCI Bridge\n"); @@ -309,8 +311,8 @@ for (i=0x0;i