net_tulip: L80225 transceiver emulation
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
set(net_sources)
|
||||
list(APPEND net_sources network.c net_pcap.c net_slirp.c net_dp8390.c net_3c501.c
|
||||
net_3c503.c net_ne2000.c net_pcnet.c net_wd8003.c net_plip.c net_event.c net_null.c
|
||||
net_eeprom_nmc93cxx.c net_tulip.c net_rtl8139.c)
|
||||
net_eeprom_nmc93cxx.c net_tulip.c net_rtl8139.c net_l80225.c)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SLIRP REQUIRED IMPORTED_TARGET slirp)
|
||||
|
||||
42
src/network/net_l80225.c
Normal file
42
src/network/net_l80225.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <86box/86box.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/pci.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/dma.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/thread.h>
|
||||
#include <86box/network.h>
|
||||
|
||||
uint16_t
|
||||
l80225_mii_readw(uint16_t* regs, uint16_t addr)
|
||||
{
|
||||
switch (addr)
|
||||
{
|
||||
case 0x1:
|
||||
return 0x782D;
|
||||
case 0x2:
|
||||
return 0b10110;
|
||||
case 0x3:
|
||||
return 0xF830;
|
||||
case 0x5:
|
||||
return 0x41E1;
|
||||
case 0x18:
|
||||
return 0xC0;
|
||||
default:
|
||||
return regs[addr];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
l80225_mii_writew(uint16_t* regs, uint16_t addr, uint16_t val)
|
||||
{
|
||||
regs[addr] = val;
|
||||
}
|
||||
@@ -660,7 +660,7 @@ static const uint16_t tulip_mdi_default[] = {
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x3800,
|
||||
0x0000,
|
||||
/* MDI Registers 16 - 31 */
|
||||
0x0003,
|
||||
@@ -683,6 +683,7 @@ static const uint16_t tulip_mdi_default[] = {
|
||||
|
||||
/* Readonly mask for MDI (PHY) registers */
|
||||
static const uint16_t tulip_mdi_mask[] = {
|
||||
/* MDI Registers 0 - 6, 7 */
|
||||
0x0000,
|
||||
0xffff,
|
||||
0xffff,
|
||||
@@ -691,6 +692,7 @@ static const uint16_t tulip_mdi_mask[] = {
|
||||
0xffff,
|
||||
0xffff,
|
||||
0x0000,
|
||||
/* MDI Registers 8 - 15 */
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
@@ -699,6 +701,7 @@ static const uint16_t tulip_mdi_mask[] = {
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
/* MDI Registers 16 - 31 */
|
||||
0x0fff,
|
||||
0x0000,
|
||||
0xffff,
|
||||
@@ -717,12 +720,15 @@ static const uint16_t tulip_mdi_mask[] = {
|
||||
0x0000,
|
||||
};
|
||||
|
||||
extern uint16_t l80225_mii_readw(uint16_t* regs, uint16_t addr);
|
||||
extern void l80225_mii_writew(uint16_t* regs, uint16_t addr, uint16_t val);
|
||||
|
||||
static uint16_t
|
||||
tulip_mii_read(TULIPState *s, int phy, int reg)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
if (phy == 1) {
|
||||
ret = s->mii_regs[reg];
|
||||
ret = l80225_mii_readw(s->mii_regs, reg);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -734,8 +740,7 @@ tulip_mii_write(TULIPState *s, int phy, int reg, uint16_t data)
|
||||
return;
|
||||
}
|
||||
|
||||
s->mii_regs[reg] &= ~tulip_mdi_mask[reg];
|
||||
s->mii_regs[reg] |= (data & tulip_mdi_mask[reg]);
|
||||
return l80225_mii_writew(s->mii_regs, reg, data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user