/[dynamips]/trunk/dev_c7200_serial.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

Annotation of /trunk/dev_c7200_serial.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (hide annotations)
Sat Oct 6 16:33:40 2007 UTC (16 years, 6 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.8-RC1/dev_c7200_serial.c
File MIME type: text/plain
File size: 6027 byte(s)
dynamips-0.2.8-RC1

1 dpavlin 1 /*
2 dpavlin 7 * Cisco router simulation platform.
3 dpavlin 1 * Copyright (C) 2005,2006 Christophe Fillot. All rights reserved.
4     *
5     * Serial Interfaces (Mueslix).
6     *
7     * EEPROM types:
8     * - 0x0C: PA-4T+
9     * - 0x0D: PA-8T-V35
10     * - 0x0E: PA-8T-X21
11     * - 0x0F: PA-8T-232
12     * - 0x10: PA-2H (HSSI)
13     * - 0x40: PA-4E1G/120
14     *
15     * It seems that the PA-8T is a combination of two PA-4T+.
16     *
17     * Note: "debug serial mueslix" gives more technical info.
18     */
19    
20     #include <stdio.h>
21     #include <stdlib.h>
22     #include <string.h>
23     #include <unistd.h>
24     #include <errno.h>
25     #include <assert.h>
26    
27 dpavlin 7 #include "cpu.h"
28     #include "vm.h"
29 dpavlin 1 #include "dynamips.h"
30     #include "memory.h"
31     #include "device.h"
32     #include "net.h"
33     #include "net_io.h"
34     #include "ptask.h"
35     #include "dev_mueslix.h"
36     #include "dev_c7200.h"
37    
38     /* ====================================================================== */
39     /* PA-4T+ */
40     /* ====================================================================== */
41    
42     /*
43     * dev_c7200_pa_4t_init()
44     *
45     * Add a PA-4T port adapter into specified slot.
46     */
47 dpavlin 11 static int dev_c7200_pa_4t_init(vm_instance_t *vm,struct cisco_card *card)
48 dpavlin 1 {
49     struct mueslix_data *data;
50 dpavlin 11 u_int slot = card->slot_id;
51 dpavlin 1
52 dpavlin 11 /* Set the PCI bus */
53     card->pci_bus = vm->slots_pci_bus[slot];
54    
55 dpavlin 1 /* Set the EEPROM */
56 dpavlin 11 cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-4T+"));
57     c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
58 dpavlin 1
59     /* Create the Mueslix chip */
60 dpavlin 11 data = dev_mueslix_init(vm,card->dev_name,1,
61     card->pci_bus,0,
62     c7200_net_irq_for_slot_port(slot,0));
63 dpavlin 1 if (!data) return(-1);
64    
65     /* Store device info into the router structure */
66 dpavlin 11 card->drv_info = data;
67     return(0);
68 dpavlin 1 }
69    
70     /* Remove a PA-4T+ from the specified slot */
71 dpavlin 11 static int dev_c7200_pa_4t_shutdown(vm_instance_t *vm,struct cisco_card *card)
72 dpavlin 1 {
73 dpavlin 11 /* Remove the PA EEPROM */
74     cisco_card_unset_eeprom(card);
75     c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL);
76    
77     /* Remove the Mueslix chip */
78     dev_mueslix_remove(card->drv_info);
79 dpavlin 1 return(0);
80     }
81    
82     /* Bind a Network IO descriptor to a specific port */
83 dpavlin 11 static int dev_c7200_pa_4t_set_nio(vm_instance_t *vm,struct cisco_card *card,
84     u_int port_id,netio_desc_t *nio)
85 dpavlin 1 {
86 dpavlin 11 struct mueslix_data *data = card->drv_info;
87 dpavlin 1
88 dpavlin 11 if (!data || (port_id >= MUESLIX_NR_CHANNELS))
89 dpavlin 1 return(-1);
90    
91     return(dev_mueslix_set_nio(data,port_id,nio));
92     }
93    
94     /* Unbind a Network IO descriptor to a specific port */
95 dpavlin 11 static int dev_c7200_pa_4t_unset_nio(vm_instance_t *vm,struct cisco_card *card,
96     u_int port_id)
97 dpavlin 1 {
98 dpavlin 11 struct mueslix_data *data = card->drv_info;
99 dpavlin 1
100 dpavlin 11 if (!data || (port_id >= MUESLIX_NR_CHANNELS))
101 dpavlin 1 return(-1);
102    
103 dpavlin 11 return(dev_mueslix_unset_nio(data,port_id));
104 dpavlin 1 }
105    
106     /* PA-4T+ driver */
107 dpavlin 11 struct cisco_card_driver dev_c7200_pa_4t_driver = {
108     "PA-4T+", 1, 0,
109 dpavlin 1 dev_c7200_pa_4t_init,
110     dev_c7200_pa_4t_shutdown,
111 dpavlin 11 NULL,
112 dpavlin 1 dev_c7200_pa_4t_set_nio,
113     dev_c7200_pa_4t_unset_nio,
114     };
115    
116     /* ====================================================================== */
117     /* PA-8T */
118     /* ====================================================================== */
119    
120     /* PA-8T data */
121     struct pa8t_data {
122     struct mueslix_data *mueslix[2];
123     };
124    
125     /*
126     * dev_c7200_pa_8t_init()
127     *
128     * Add a PA-8T port adapter into specified slot.
129     */
130 dpavlin 11 static int dev_c7200_pa_8t_init(vm_instance_t *vm,struct cisco_card *card)
131 dpavlin 1 {
132     struct pa8t_data *data;
133 dpavlin 11 u_int slot = card->slot_id;
134 dpavlin 1
135     /* Allocate the private data structure for the PA-8T */
136     if (!(data = malloc(sizeof(*data)))) {
137 dpavlin 11 vm_log(vm,"%s: out of memory\n",card->dev_name);
138 dpavlin 1 return(-1);
139     }
140    
141 dpavlin 11 /* Set the PCI bus */
142     card->pci_bus = vm->slots_pci_bus[slot];
143    
144 dpavlin 1 /* Set the EEPROM */
145 dpavlin 11 cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-8T"));
146     c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
147 dpavlin 1
148     /* Create the 1st Mueslix chip */
149 dpavlin 11 data->mueslix[0] = dev_mueslix_init(vm,card->dev_name,1,
150     card->pci_bus,0,
151     c7200_net_irq_for_slot_port(slot,0));
152 dpavlin 1 if (!data->mueslix[0]) return(-1);
153    
154     /* Create the 2nd Mueslix chip */
155 dpavlin 11 data->mueslix[1] = dev_mueslix_init(vm,card->dev_name,1,
156     card->pci_bus,1,
157     c7200_net_irq_for_slot_port(slot,1));
158 dpavlin 1 if (!data->mueslix[1]) return(-1);
159    
160     /* Store device info into the router structure */
161 dpavlin 11 card->drv_info = data;
162     return(0);
163 dpavlin 1 }
164    
165     /* Remove a PA-8T from the specified slot */
166 dpavlin 11 static int dev_c7200_pa_8t_shutdown(vm_instance_t *vm,struct cisco_card *card)
167 dpavlin 1 {
168 dpavlin 11 struct pa8t_data *data = card->drv_info;
169 dpavlin 1
170     /* Remove the PA EEPROM */
171 dpavlin 11 cisco_card_unset_eeprom(card);
172     c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL);
173 dpavlin 1
174     /* Remove the two Mueslix chips */
175     dev_mueslix_remove(data->mueslix[0]);
176     dev_mueslix_remove(data->mueslix[1]);
177     free(data);
178     return(0);
179     }
180    
181     /* Bind a Network IO descriptor to a specific port */
182 dpavlin 11 static int dev_c7200_pa_8t_set_nio(vm_instance_t *vm,struct cisco_card *card,
183     u_int port_id,netio_desc_t *nio)
184 dpavlin 1 {
185 dpavlin 11 struct pa8t_data *d = card->drv_info;
186 dpavlin 1
187 dpavlin 11 if (!d || (port_id >= (MUESLIX_NR_CHANNELS*2)))
188 dpavlin 1 return(-1);
189    
190     return(dev_mueslix_set_nio(d->mueslix[port_id>>2],(port_id&0x03),nio));
191     }
192    
193     /* Bind a Network IO descriptor to a specific port */
194 dpavlin 11 static int dev_c7200_pa_8t_unset_nio(vm_instance_t *vm,struct cisco_card *card,
195     u_int port_id)
196 dpavlin 1 {
197 dpavlin 11 struct pa8t_data *d = card->drv_info;
198 dpavlin 1
199 dpavlin 11 if (!d || (port_id >= (MUESLIX_NR_CHANNELS*2)))
200 dpavlin 1 return(-1);
201    
202     return(dev_mueslix_unset_nio(d->mueslix[port_id>>2],port_id&0x03));
203     }
204    
205     /* PA-8T driver */
206 dpavlin 11 struct cisco_card_driver dev_c7200_pa_8t_driver = {
207     "PA-8T", 1, 0,
208 dpavlin 1 dev_c7200_pa_8t_init,
209     dev_c7200_pa_8t_shutdown,
210 dpavlin 11 NULL,
211 dpavlin 1 dev_c7200_pa_8t_set_nio,
212     dev_c7200_pa_8t_unset_nio,
213     };

  ViewVC Help
Powered by ViewVC 1.1.26