/[dynamips]/trunk/dev_c3725_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_c3725_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: 2707 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 c3725 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_c3725.h"
24
25 /* Initialize a NM PC module in the specified slot */
26 static int dev_c3725_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 /* Set the PCI bus */
33 card->pci_bus = vm->slots_pci_bus[slot];
34
35 /* Set the EEPROM */
36 cisco_card_set_eeprom(vm,card,cisco_eeprom_find_nm(card->driver->dev_type));
37 c3725_set_slot_eeprom(VM_C3725(vm),slot,&card->eeprom);
38
39 /* Create the Intel i8255x chip */
40 data = dev_i8255x_init(vm,card->dev_name,0,
41 card->pci_bus,
42 c3725_nm_get_pci_device(slot),
43 c3725_net_irq_for_slot_port(slot,0));
44
45 /* Store device info into the router structure */
46 card->drv_info = data;
47 return(0);
48 }
49
50 /* Remove a NM PC module from the specified slot */
51 static int dev_c3725_pcmod_shutdown(vm_instance_t *vm,struct cisco_card *card)
52 {
53 struct i8255x_data *data = card->drv_info;
54
55 /* Remove the NM EEPROM */
56 cisco_card_unset_eeprom(card);
57 c3725_set_slot_eeprom(VM_C3725(vm),card->slot_id,NULL);
58
59 /* Remove the Intel i2855x chip */
60 dev_i8255x_remove(data);
61 return(0);
62 }
63
64 /* Bind a Network IO descriptor */
65 static int dev_c3725_pcmod_set_nio(vm_instance_t *vm,struct cisco_card *card,
66 u_int port_id,netio_desc_t *nio)
67 {
68 struct i8255x_data *d = card->drv_info;
69
70 if (!d || (port_id != 0))
71 return(-1);
72
73 dev_i8255x_set_nio(d,nio);
74 return(0);
75 }
76
77 /* Unbind a Network IO descriptor */
78 static int dev_c3725_pcmod_unset_nio(vm_instance_t *vm,struct cisco_card *card,
79 u_int port_id)
80 {
81 struct i8255x_data *d = card->drv_info;
82
83 if (!d || (port_id != 0))
84 return(-1);
85
86 dev_i8255x_unset_nio(d);
87 return(0);
88 }
89
90 /* NM-NAM driver */
91 struct cisco_card_driver dev_c3725_nm_nam_driver = {
92 "NM-NAM", 0, 0,
93 dev_c3725_pcmod_init,
94 dev_c3725_pcmod_shutdown,
95 NULL,
96 dev_c3725_pcmod_set_nio,
97 dev_c3725_pcmod_unset_nio,
98 NULL,
99 };
100
101 /* NM-CIDS driver */
102 struct cisco_card_driver dev_c3725_nm_cids_driver = {
103 "NM-CIDS", 0, 0,
104 dev_c3725_pcmod_init,
105 dev_c3725_pcmod_shutdown,
106 NULL,
107 dev_c3725_pcmod_set_nio,
108 dev_c3725_pcmod_unset_nio,
109 NULL,
110 };

  ViewVC Help
Powered by ViewVC 1.1.26