/[dynamips]/trunk/dev_c2600_pcmod.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/dev_c2600_pcmod.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Sat Oct 6 16:45:40 2007 UTC (11 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 2965 byte(s)
make working copy

1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2007 Christophe Fillot (cf@utc.fr)
4 *
5 * PC Modules NM (NM-NAM, NM-CIDS, ...) for c2600 platforms.
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 "vm.h"
22 #include "dev_i8255x.h"
23 #include "dev_c2600.h"
24
25 /* Initialize a NM-NAM in the specified slot */
26 static int dev_c2600_pcmod_init(vm_instance_t *vm,struct cisco_card *card)
27 {
28
29 struct i8255x_data *data;
30 u_int slot = card->slot_id;
31
32 /*
33 * Non-XM models don't have the capability to byte-swap through their
34 * PCI host bridge (required for i82559 data transfers).
35 */
36 if (!VM_C2600(vm)->xm_model) {
37 vm_error(vm,"%s is not supported in C2600 non-XM models.\n",
38 card->driver->dev_type);
39 return(-1);
40 }
41
42 /* Set the PCI bus */
43 card->pci_bus = vm->slots_pci_bus[slot];
44
45 /* Set the EEPROM */
46 cisco_card_set_eeprom(vm,card,cisco_eeprom_find_nm(card->driver->dev_type));
47 c2600_set_slot_eeprom(VM_C2600(vm),slot,&card->eeprom);
48
49 /* Create the Intel i8255x chip */
50 data = dev_i8255x_init(vm,card->dev_name,0,
51 card->pci_bus,slot * 4,
52 c2600_net_irq_for_slot_port(slot,0));
53
54 /* Store device info into the router structure */
55 card->drv_info = data;
56 return(0);
57 }
58
59 /* Remove a NM PC module from the specified slot */
60 static int dev_c2600_pcmod_shutdown(vm_instance_t *vm,struct cisco_card *card)
61 {
62 struct i8255x_data *data = card->drv_info;
63
64 /* Remove the NM EEPROM */
65 cisco_card_unset_eeprom(card);
66 c2600_set_slot_eeprom(VM_C2600(vm),card->slot_id,NULL);
67
68 /* Remove the Intel i2855x chip */
69 dev_i8255x_remove(data);
70 return(0);
71 }
72
73 /* Bind a Network IO descriptor */
74 static int dev_c2600_pcmod_set_nio(vm_instance_t *vm,struct cisco_card *card,
75 u_int port_id,netio_desc_t *nio)
76 {
77 struct i8255x_data *d = card->drv_info;
78
79 if (!d || (port_id != 0))
80 return(-1);
81
82 dev_i8255x_set_nio(d,nio);
83 return(0);
84 }
85
86 /* Unbind a Network IO descriptor */
87 static int dev_c2600_pcmod_unset_nio(vm_instance_t *vm,struct cisco_card *card,
88 u_int port_id)
89 {
90 struct i8255x_data *d = card->drv_info;
91
92 if (!d || (port_id != 0))
93 return(-1);
94
95 dev_i8255x_unset_nio(d);
96 return(0);
97 }
98
99 /* NM-NAM driver */
100 struct cisco_card_driver dev_c2600_nm_nam_driver = {
101 "NM-NAM", 0, 0,
102 dev_c2600_pcmod_init,
103 dev_c2600_pcmod_shutdown,
104 NULL,
105 dev_c2600_pcmod_set_nio,
106 dev_c2600_pcmod_unset_nio,
107 NULL,
108 };
109
110 /* NM-CIDS driver */
111 struct cisco_card_driver dev_c2600_nm_cids_driver = {
112 "NM-CIDS", 0, 0,
113 dev_c2600_pcmod_init,
114 dev_c2600_pcmod_shutdown,
115 NULL,
116 dev_c2600_pcmod_set_nio,
117 dev_c2600_pcmod_unset_nio,
118 NULL,
119 };

  ViewVC Help
Powered by ViewVC 1.1.26