From d175b403da8b2d6ab51b32a7632758d3a234ae01 Mon Sep 17 00:00:00 2001 From: Greg Bowne Date: Mon, 16 Oct 2023 18:44:34 -0700 Subject: [PATCH] adding a NE2000 compatible network driver and updated README.md --- README.md | 27 +++++++++++++++++++++++- src/drivers/network/ne2000.c | 41 ++++++++++++++++++++++++++++++++++++ src/drivers/network/ne2000.h | 23 ++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/drivers/network/ne2000.c create mode 100644 src/drivers/network/ne2000.h diff --git a/README.md b/README.md index ad57ba9..1c48944 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ These are the versions I use, but please use the latest possible versions. - QEMU x86_64 - GNU ld (GNU Binutils for Debian) 2.31.1 or newer - dd (coreutils) 8.30 +- as (GNU Binutils for Debian) 2.31.1 or newer +- ld (GNU Binutils for Debian) 2.31.1 or newer +- cc (Debian 8.3.0-6) 8.3.0 The C and C++ standards we are using for this are C17 and C++20 @@ -20,4 +23,26 @@ For C/C++: - g++ version 8.3.0 (Debian 8.3.0-6) - GNU gdb (Debian 8.2.1-2+b3) 8.2.1 - lldb version 7.0.1 - \ No newline at end of file +- Coreutils 8.30 +- Binutils 2.31.1 +- Bison 3.3.2 +- Diffutils 3.7 +- Findutils 4.6.0.225 +- Gawk 4.2.1 +- Grep 3.3 +- Gzip 1.9 +- M4 1.4.18 +- Make 4.2.1 +- Patch 2.7.6 +- Perl 5.28.1 +- Python 3.7.3 +- Sed 4.7 +- Tar 1.30 +- Texinfo 6.5, Xz 5.2.4 + +## Features + +- Booting from 1.2M, 1.44MB, hard drive or ISO9660 +- FAT12, FAT16, FAT32, NTFS and ext2 support +- GUI +- \ No newline at end of file diff --git a/src/drivers/network/ne2000.c b/src/drivers/network/ne2000.c new file mode 100644 index 0000000..048ac62 --- /dev/null +++ b/src/drivers/network/ne2000.c @@ -0,0 +1,41 @@ +#include + +// NE2000 registers +#define NE2000_COMMAND 0x00 +#define NE2000_PSTART 0x01 +#define NE2000_PSTOP 0x02 +// ... more registers ... + +// NE2000 commands +#define NE2000_CMD_START 0x02 +#define NE2000_CMD_STOP 0x01 +// ... more commands ... + +// Write a value to a NE2000 register +void ne2000_write_reg(uint16_t base_addr, uint8_t reg, uint8_t value) { + // Write to the register + // This will depend on your specific hardware interface +} + +// Read a value from a NE2000 register +uint8_t ne2000_read_reg(uint16_t base_addr, uint8_t reg) { + // Read from the register + // This will depend on your specific hardware interface +} + +// Initialize the NE2000 card +void ne2000_init(uint16_t base_addr) { + // Stop the NE2000 card + ne2000_write_reg(base_addr, NE2000_COMMAND, NE2000_CMD_STOP); + + // Set up the packet buffer + ne2000_write_reg(base_addr, NE2000_PSTART, 0x40); + ne2000_write_reg(base_addr, NE2000_PSTOP, 0x80); + + // ... more initialization ... + + // Start the NE2000 card + ne2000_write_reg(base_addr, NE2000_COMMAND, NE2000_CMD_START); +} + +// ... more driver functions .. \ No newline at end of file diff --git a/src/drivers/network/ne2000.h b/src/drivers/network/ne2000.h new file mode 100644 index 0000000..43f05bb --- /dev/null +++ b/src/drivers/network/ne2000.h @@ -0,0 +1,23 @@ +#ifndef NE2000_H +#define NE2000_H + +#include + +// NE2000 registers +#define NE2000_COMMAND 0x00 +#define NE2000_PSTART 0x01 +#define NE2000_PSTOP 0x02 +// ... more registers ... + +// NE2000 commands +#define NE2000_CMD_START 0x02 +#define NE2000_CMD_STOP 0x01 +// ... more commands ... + +// Function prototypes +void ne2000_write_reg(uint16_t base_addr, uint8_t reg, uint8_t value); +uint8_t ne2000_read_reg(uint16_t base_addr, uint8_t reg); +void ne2000_init(uint16_t base_addr); +// ... more function prototypes ... + +#endif // NE2000_H \ No newline at end of file