1 |
/* |
2 |
* Cisco router simulation platform. |
3 |
* Copyright (c) 2006 Christophe Fillot (cf@utc.fr) |
4 |
* |
5 |
* Serial Network Modules. |
6 |
*/ |
7 |
|
8 |
#include <stdio.h> |
9 |
#include <stdlib.h> |
10 |
#include <string.h> |
11 |
#include <stdarg.h> |
12 |
#include <unistd.h> |
13 |
#include <time.h> |
14 |
#include <errno.h> |
15 |
#include <assert.h> |
16 |
|
17 |
#include "utils.h" |
18 |
#include "net.h" |
19 |
#include "net_io.h" |
20 |
#include "ptask.h" |
21 |
#include "dev_mueslix.h" |
22 |
#include "dev_c3745.h" |
23 |
|
24 |
/* ====================================================================== */ |
25 |
/* NM-4T */ |
26 |
/* ====================================================================== */ |
27 |
|
28 |
/* |
29 |
* dev_c3745_nm_4t_init() |
30 |
* |
31 |
* Add a NM-4T network module into specified slot. |
32 |
*/ |
33 |
int dev_c3745_nm_4t_init(vm_instance_t *vm,struct cisco_card *card) |
34 |
{ |
35 |
struct mueslix_data *data; |
36 |
u_int slot = card->slot_id; |
37 |
|
38 |
/* Set the PCI bus */ |
39 |
card->pci_bus = vm->slots_pci_bus[slot]; |
40 |
|
41 |
/* Set the EEPROM */ |
42 |
cisco_card_set_eeprom(vm,card,cisco_eeprom_find_nm("NM-4T")); |
43 |
c3745_set_slot_eeprom(VM_C3745(vm),slot,&card->eeprom); |
44 |
|
45 |
/* Create the Mueslix chip */ |
46 |
data = dev_mueslix_init(vm,card->dev_name,0,card->pci_bus,0, |
47 |
c3745_net_irq_for_slot_port(slot,0)); |
48 |
|
49 |
if (!data) return(-1); |
50 |
|
51 |
/* Store device info into the router structure */ |
52 |
card->drv_info = data; |
53 |
return(0); |
54 |
} |
55 |
|
56 |
/* Remove a NM-4T from the specified slot */ |
57 |
int dev_c3745_nm_4t_shutdown(vm_instance_t *vm,struct cisco_card *card) |
58 |
{ |
59 |
/* Remove the NM EEPROM */ |
60 |
cisco_card_unset_eeprom(card); |
61 |
c3745_set_slot_eeprom(VM_C3745(vm),card->slot_id,NULL); |
62 |
|
63 |
/* Remove the mueslix driver */ |
64 |
dev_mueslix_remove(card->drv_info); |
65 |
return(0); |
66 |
} |
67 |
|
68 |
/* Bind a Network IO descriptor to a specific port */ |
69 |
int dev_c3745_nm_4t_set_nio(vm_instance_t *vm,struct cisco_card *card, |
70 |
u_int port_id,netio_desc_t *nio) |
71 |
{ |
72 |
struct mueslix_data *d = card->drv_info; |
73 |
|
74 |
if (!d || (port_id >= MUESLIX_NR_CHANNELS)) |
75 |
return(-1); |
76 |
|
77 |
return(dev_mueslix_set_nio(d,port_id,nio)); |
78 |
} |
79 |
|
80 |
/* Unbind a Network IO descriptor to a specific port */ |
81 |
int dev_c3745_nm_4t_unset_nio(vm_instance_t *vm,struct cisco_card *card, |
82 |
u_int port_id) |
83 |
{ |
84 |
struct mueslix_data *d = card->drv_info; |
85 |
|
86 |
if (!d || (port_id >= MUESLIX_NR_CHANNELS)) |
87 |
return(-1); |
88 |
|
89 |
return(dev_mueslix_unset_nio(d,port_id)); |
90 |
} |
91 |
|
92 |
/* NM-4T driver */ |
93 |
struct cisco_card_driver dev_c3745_nm_4t_driver = { |
94 |
"NM-4T", 1, 0, |
95 |
dev_c3745_nm_4t_init, |
96 |
dev_c3745_nm_4t_shutdown, |
97 |
NULL, |
98 |
dev_c3745_nm_4t_set_nio, |
99 |
dev_c3745_nm_4t_unset_nio, |
100 |
NULL, |
101 |
}; |