Permalink
Browse files

Files for Part 18, https://www.youtube.com/watch?v=DrZIkxqtdYc

  • Loading branch information...
AlgorithMan-de committed Jul 23, 2016
1 parent 7a49a16 commit c2fd644933165e38d8b564f0604407da772bcb89
Showing with 66 additions and 6 deletions.
  1. +2 −1 include/drivers/amd_am79c973.h
  2. +1 −1 include/drivers/driver.h
  3. +55 −3 src/drivers/amd_am79c973.cpp
  4. +8 −1 src/kernel.cpp
@@ -71,7 +71,8 @@ namespace myos
int Reset();
common::uint32_t HandleInterrupt(common::uint32_t esp);
void Send(common::uint8_t* buffer, int count);
void Receive();
};
View
@@ -20,7 +20,7 @@ namespace myos
class DriverManager
{
private:
public:
Driver* drivers[265];
int numDrivers;
@@ -108,6 +108,7 @@ int amd_am79c973::Reset()
void printf(char*);
void printfHex(uint8_t);
uint32_t amd_am79c973::HandleInterrupt(common::uint32_t esp)
{
@@ -120,15 +121,66 @@ uint32_t amd_am79c973::HandleInterrupt(common::uint32_t esp)
if((temp & 0x2000) == 0x2000) printf("AMD am79c973 COLLISION ERROR\n");
if((temp & 0x1000) == 0x1000) printf("AMD am79c973 MISSED FRAME\n");
if((temp & 0x0800) == 0x0800) printf("AMD am79c973 MEMORY ERROR\n");
if((temp & 0x0400) == 0x0400) printf("AMD am79c973 DATA RECEVED\n");
if((temp & 0x0400) == 0x0400) Receive();
if((temp & 0x0200) == 0x0200) printf("AMD am79c973 DATA SENT\n");
// acknoledge
registerAddressPort.Write(0);
registerDataPort.Write(temp);
if((temp & 0x0200) == 0x0200) printf("AMD am79c973 INIT DONE\n");
if((temp & 0x0100) == 0x0100) printf("AMD am79c973 INIT DONE\n");
return esp;
}
void amd_am79c973::Send(uint8_t* buffer, int size)
{
int sendDescriptor = currentSendBuffer;
currentSendBuffer = (currentSendBuffer + 1) % 8;
if(size > 1518)
size = 1518;
for(uint8_t *src = buffer + size -1,
*dst = (uint8_t*)(sendBufferDescr[sendDescriptor].address + size -1);
src >= buffer; src--, dst--)
*dst = *src;
sendBufferDescr[sendDescriptor].avail = 0;
sendBufferDescr[sendDescriptor].flags2 = 0;
sendBufferDescr[sendDescriptor].flags = 0x8300F000
| ((uint16_t)((-size) & 0xFFF));
registerAddressPort.Write(0);
registerDataPort.Write(0x48);
}
void amd_am79c973::Receive()
{
printf("AMD am79c973 DATA RECEIVED\n");
for(; (recvBufferDescr[currentRecvBuffer].flags & 0x80000000) == 0;
currentRecvBuffer = (currentRecvBuffer + 1) % 8)
{
if(!(recvBufferDescr[currentRecvBuffer].flags & 0x40000000)
&& (recvBufferDescr[currentRecvBuffer].flags & 0x03000000) == 0x03000000)
{
uint32_t size = recvBufferDescr[currentRecvBuffer].flags & 0xFFF;
if(size > 64) // remove checksum
size -= 4;
uint8_t* buffer = (uint8_t*)(recvBufferDescr[currentRecvBuffer].address);
for(int i = 0; i < size; i++)
{
printfHex(buffer[i]);
printf(" ");
}
}
recvBufferDescr[currentRecvBuffer].flags2 = 0;
recvBufferDescr[currentRecvBuffer].flags = 0x8000F7FF;
}
}
View
@@ -12,6 +12,8 @@
#include <gui/window.h>
#include <multitasking.h>
#include <drivers/amd_am79c973.h>
// #define GRAPHICSMODE
@@ -188,7 +190,7 @@ extern "C" void kernelMain(const void* multiboot_structure, uint32_t /*multiboot
printfHex(((size_t)allocated >> 8 ) & 0xFF);
printfHex(((size_t)allocated ) & 0xFF);
printf("\n");
TaskManager taskManager;
/*
Task task1(&gdt, taskA);
@@ -242,6 +244,11 @@ extern "C" void kernelMain(const void* multiboot_structure, uint32_t /*multiboot
desktop.AddChild(&win2);
#endif
amd_am79c973* eth0 = (amd_am79c973*)(drvManager.drivers[2]);
eth0->Send((uint8_t*)"Hello Network", 13);
interrupts.Activate();

0 comments on commit c2fd644

Please sign in to comment.