mirror of https://gitee.com/openkylin/qemu.git
Allow selection of emulated network card.
rtl8139 emulation. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1745 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
d861b05ea3
commit
a41b2ff2dd
|
@ -307,26 +307,29 @@ endif
|
|||
# USB layer
|
||||
VL_OBJS+= usb.o usb-uhci.o usb-linux.o usb-hid.o
|
||||
|
||||
# PCI network cards
|
||||
VL_OBJS+= ne2000.o rtl8139.o
|
||||
|
||||
ifeq ($(TARGET_BASE_ARCH), i386)
|
||||
# Hardware support
|
||||
VL_OBJS+= ide.o ne2000.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
|
||||
VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
|
||||
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
|
||||
VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
|
||||
DEFINES += -DHAS_AUDIO
|
||||
endif
|
||||
ifeq ($(TARGET_BASE_ARCH), ppc)
|
||||
VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
|
||||
VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
|
||||
VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
|
||||
VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
|
||||
DEFINES += -DHAS_AUDIO
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH), mips)
|
||||
VL_OBJS+= mips_r4k.o dma.o vga.o serial.o ne2000.o i8254.o i8259.o
|
||||
VL_OBJS+= mips_r4k.o dma.o vga.o serial.o i8254.o i8259.o
|
||||
#VL_OBJS+= #ide.o pckbd.o fdc.o m48t59.o
|
||||
endif
|
||||
ifeq ($(TARGET_BASE_ARCH), sparc)
|
||||
ifeq ($(TARGET_ARCH), sparc64)
|
||||
VL_OBJS+= sun4u.o ide.o ne2000.o pckbd.o ps2.o vga.o
|
||||
VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o
|
||||
VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
|
||||
VL_OBJS+= cirrus_vga.o parallel.o
|
||||
VL_OBJS+= magic-load.o
|
||||
|
|
|
@ -1195,8 +1195,15 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
|
|||
icp_control_init(0xcb000000);
|
||||
icp_kmi_init(0x18000000, pic, 3, 0);
|
||||
icp_kmi_init(0x19000000, pic, 4, 1);
|
||||
if (nd_table[0].vlan)
|
||||
smc91c111_init(&nd_table[0], 0xc8000000, pic, 27);
|
||||
if (nd_table[0].vlan) {
|
||||
if (nd_table[0].model == NULL
|
||||
|| strcmp(nd_table[0].model, "smc91c111") == 0) {
|
||||
smc91c111_init(&nd_table[0], 0xc8000000, pic, 27);
|
||||
} else {
|
||||
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Load the kernel. */
|
||||
if (!kernel_filename) {
|
||||
|
|
|
@ -272,8 +272,15 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
|
|||
vga_initialize(NULL, ds, phys_ram_base + ram_size, ram_size,
|
||||
vga_ram_size, 0, 0);
|
||||
|
||||
if (nd_table[0].vlan)
|
||||
isa_ne2000_init(0x300, 9, &nd_table[0]);
|
||||
if (nd_table[0].vlan) {
|
||||
if (nd_table[0].model == NULL
|
||||
|| strcmp(nd_table[0].model, "ne2k_isa") == 0) {
|
||||
isa_ne2000_init(0x300, 9, &nd_table[0]);
|
||||
} else {
|
||||
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QEMUMachine mips_machine = {
|
||||
|
|
42
hw/pc.c
42
hw/pc.c
|
@ -606,6 +606,16 @@ static void audio_init (PCIBus *pci_bus)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void pc_init_ne2k_isa(NICInfo *nd)
|
||||
{
|
||||
static int nb_ne2k = 0;
|
||||
|
||||
if (nb_ne2k == NE2000_NB_MAX)
|
||||
return;
|
||||
isa_ne2000_init(ne2000_io[nb_ne2k], ne2000_irq[nb_ne2k], nd);
|
||||
nb_ne2k++;
|
||||
}
|
||||
|
||||
/* PC hardware initialisation */
|
||||
static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
|
||||
DisplayState *ds, const char **fd_filename, int snapshot,
|
||||
|
@ -614,11 +624,12 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
|
|||
int pci_enabled)
|
||||
{
|
||||
char buf[1024];
|
||||
int ret, linux_boot, initrd_size, i, nb_nics1;
|
||||
int ret, linux_boot, initrd_size, i;
|
||||
unsigned long bios_offset, vga_bios_offset;
|
||||
int bios_size, isa_bios_size;
|
||||
PCIBus *pci_bus;
|
||||
CPUState *env;
|
||||
NICInfo *nd;
|
||||
|
||||
linux_boot = (kernel_filename != NULL);
|
||||
|
||||
|
@ -800,19 +811,28 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
|
|||
}
|
||||
}
|
||||
|
||||
if (pci_enabled) {
|
||||
for(i = 0; i < nb_nics; i++) {
|
||||
pci_ne2000_init(pci_bus, &nd_table[i]);
|
||||
for(i = 0; i < nb_nics; i++) {
|
||||
nd = &nd_table[i];
|
||||
if (!nd->model) {
|
||||
if (pci_enabled) {
|
||||
nd->model = "ne2k_pci";
|
||||
} else {
|
||||
nd->model = "ne2k_isa";
|
||||
}
|
||||
}
|
||||
if (strcmp(nd->model, "ne2k_isa") == 0) {
|
||||
pc_init_ne2k_isa(nd);
|
||||
} else if (pci_enabled) {
|
||||
pci_nic_init(pci_bus, nd);
|
||||
} else {
|
||||
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (pci_enabled) {
|
||||
pci_piix3_ide_init(pci_bus, bs_table);
|
||||
} else {
|
||||
nb_nics1 = nb_nics;
|
||||
if (nb_nics1 > NE2000_NB_MAX)
|
||||
nb_nics1 = NE2000_NB_MAX;
|
||||
for(i = 0; i < nb_nics1; i++) {
|
||||
isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < 2; i++) {
|
||||
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
|
||||
bs_table[2 * i], bs_table[2 * i + 1]);
|
||||
|
|
14
hw/pci.c
14
hw/pci.c
|
@ -1837,3 +1837,17 @@ void pci_bios_init(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize a PCI NIC. */
|
||||
void pci_nic_init(PCIBus *bus, NICInfo *nd)
|
||||
{
|
||||
if (strcmp(nd->model, "ne2k_pci") == 0) {
|
||||
pci_ne2000_init(bus, nd);
|
||||
} else if (strcmp(nd->model, "rtl8139") == 0) {
|
||||
pci_rtl8139_init(bus, nd);
|
||||
} else {
|
||||
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -436,7 +436,9 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
|
|||
serial_init(&pic_set_irq_new, isa_pic, 0x3f8, 4, serial_hds[0]);
|
||||
|
||||
for(i = 0; i < nb_nics; i++) {
|
||||
pci_ne2000_init(pci_bus, &nd_table[i]);
|
||||
if (!nd_table[i].model)
|
||||
nd_table[i].model = "ne2k_pci";
|
||||
pci_nic_init(pci_bus, &nd_table[i]);
|
||||
}
|
||||
|
||||
pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
|
||||
|
|
|
@ -624,7 +624,13 @@ static void ppc_prep_init(int ram_size, int vga_ram_size, int boot_device,
|
|||
if (nb_nics1 > NE2000_NB_MAX)
|
||||
nb_nics1 = NE2000_NB_MAX;
|
||||
for(i = 0; i < nb_nics1; i++) {
|
||||
isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
|
||||
if (nd_table[0].model == NULL
|
||||
|| strcmp(nd_table[0].model, "ne2k_isa") == 0) {
|
||||
isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
|
||||
} else {
|
||||
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < 2; i++) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
10
hw/sun4m.c
10
hw/sun4m.c
|
@ -257,7 +257,15 @@ static void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
|
|||
}
|
||||
|
||||
tcx = tcx_init(ds, PHYS_JJ_TCX_FB, phys_ram_base + ram_size, ram_size, vram_size, graphic_width, graphic_height);
|
||||
lance_init(&nd_table[0], PHYS_JJ_LE_IRQ, PHYS_JJ_LE, PHYS_JJ_LEDMA);
|
||||
if (nd_table[0].vlan) {
|
||||
if (nd_table[0].model == NULL
|
||||
|| strcmp(nd_table[0].model, "lance") == 0) {
|
||||
lance_init(&nd_table[0], PHYS_JJ_LE_IRQ, PHYS_JJ_LE, PHYS_JJ_LEDMA);
|
||||
} else {
|
||||
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
nvram = m48t59_init(0, PHYS_JJ_EEPROM, 0, PHYS_JJ_EEPROM_SIZE, 8);
|
||||
for (i = 0; i < MAX_CPUS; i++) {
|
||||
slavio_timer_init(PHYS_JJ_CLOCK + i * TARGET_PAGE_SIZE, PHYS_JJ_CLOCK_IRQ, 0, i);
|
||||
|
|
|
@ -347,7 +347,9 @@ static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
|
|||
}
|
||||
|
||||
for(i = 0; i < nb_nics; i++) {
|
||||
pci_ne2000_init(pci_bus, &nd_table[i]);
|
||||
if (!nd_table[i].model)
|
||||
nd_table[i].model = "ne2k_pci";
|
||||
pci_nic_init(pci_bus, &nd_table[i]);
|
||||
}
|
||||
|
||||
pci_cmd646_ide_init(pci_bus, bs_table, 1);
|
||||
|
|
|
@ -252,11 +252,15 @@ Network options:
|
|||
|
||||
@table @option
|
||||
|
||||
@item -net nic[,vlan=n][,macaddr=addr]
|
||||
@item -net nic[,vlan=n][,macaddr=addr][,model=type]
|
||||
Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
|
||||
= 0 is the default). The NIC is currently an NE2000 on the PC
|
||||
target. Optionally, the MAC address can be changed. If no
|
||||
@option{-net} option is specified, a single NIC is created.
|
||||
Qemu can emulate several different models of network card. Valid values for
|
||||
@var{type} are @code{ne2k_pci}, @code{ne2k_isa}, @code{rtl8139},
|
||||
@code{smc91c111} and @code{lance}. Not all devices are supported on all
|
||||
targets.
|
||||
|
||||
@item -net user[,vlan=n]
|
||||
Use the user mode network stack which requires no administrator
|
||||
|
|
5
vl.c
5
vl.c
|
@ -2718,6 +2718,9 @@ int net_client_init(const char *str)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
if (get_param_value(buf, sizeof(buf), "model", p)) {
|
||||
nd->model = strdup(buf);
|
||||
}
|
||||
nd->vlan = vlan;
|
||||
nb_nics++;
|
||||
ret = 0;
|
||||
|
@ -4110,7 +4113,7 @@ void help(void)
|
|||
#endif
|
||||
"\n"
|
||||
"Network options:\n"
|
||||
"-net nic[,vlan=n][,macaddr=addr]\n"
|
||||
"-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
|
||||
" create a new Network Interface Card and connect it to VLAN 'n'\n"
|
||||
#ifdef CONFIG_SLIRP
|
||||
"-net user[,vlan=n]\n"
|
||||
|
|
7
vl.h
7
vl.h
|
@ -315,6 +315,7 @@ void tap_win32_poll(void);
|
|||
|
||||
typedef struct NICInfo {
|
||||
uint8_t macaddr[6];
|
||||
const char *model;
|
||||
VLANState *vlan;
|
||||
} NICInfo;
|
||||
|
||||
|
@ -616,6 +617,8 @@ PCIBus *pci_grackle_init(uint32_t base);
|
|||
PCIBus *pci_pmac_init(void);
|
||||
PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base);
|
||||
|
||||
void pci_nic_init(PCIBus *bus, NICInfo *nd);
|
||||
|
||||
/* openpic.c */
|
||||
typedef struct openpic_t openpic_t;
|
||||
void openpic_set_irq(void *opaque, int n_IRQ, int level);
|
||||
|
@ -740,6 +743,10 @@ int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
|
|||
void isa_ne2000_init(int base, int irq, NICInfo *nd);
|
||||
void pci_ne2000_init(PCIBus *bus, NICInfo *nd);
|
||||
|
||||
/* rtl8139.c */
|
||||
|
||||
void pci_rtl8139_init(PCIBus *bus, NICInfo *nd);
|
||||
|
||||
/* pckbd.c */
|
||||
|
||||
void kbd_init(void);
|
||||
|
|
Loading…
Reference in New Issue