/[dynamips]/upstream/dynamips-0.2.6-RC3/dev_c2691_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

Contents of /upstream/dynamips-0.2.6-RC3/dev_c2691_serial.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations)
Sat Oct 6 16:06:49 2007 UTC (12 years, 1 month ago) by dpavlin
File MIME type: text/plain
File size: 2469 byte(s)
dynamips-0.2.6-RC3

1 /*
2 * Cisco C2691 (Predator) 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_c2691.h"
23
24 /* ====================================================================== */
25 /* NM-4T */
26 /* ====================================================================== */
27
28 /*
29 * dev_c2691_nm_4t_init()
30 *
31 * Add a NM-4T network module into specified slot.
32 */
33 int dev_c2691_nm_4t_init(c2691_t *router,char *name,u_int nm_bay)
34 {
35 struct mueslix_data *data;
36
37 /* Set the EEPROM */
38 c2691_nm_set_eeprom(router,nm_bay,cisco_eeprom_find_nm("NM-4T"));
39
40 /* Create the Mueslix chip */
41 data = dev_mueslix_init(router->vm,name,0,
42 router->nm_bay[nm_bay].pci_map,
43 6,C2691_NETIO_IRQ);
44
45 if (!data) return(-1);
46
47 /* Store device info into the router structure */
48 return(c2691_nm_set_drvinfo(router,nm_bay,data));
49 }
50
51 /* Remove a NM-4T from the specified slot */
52 int dev_c2691_nm_4t_shutdown(c2691_t *router,u_int nm_bay)
53 {
54 struct c2691_nm_bay *bay;
55
56 if (!(bay = c2691_nm_get_info(router,nm_bay)))
57 return(-1);
58
59 c2691_nm_unset_eeprom(router,nm_bay);
60 dev_mueslix_remove(bay->drv_info);
61 return(0);
62 }
63
64 /* Bind a Network IO descriptor to a specific port */
65 int dev_c2691_nm_4t_set_nio(c2691_t *router,u_int nm_bay,u_int port_id,
66 netio_desc_t *nio)
67 {
68 struct mueslix_data *data;
69
70 if ((port_id >= MUESLIX_NR_CHANNELS) ||
71 !(data = c2691_nm_get_drvinfo(router,nm_bay)))
72 return(-1);
73
74 return(dev_mueslix_set_nio(data,port_id,nio));
75 }
76
77 /* Unbind a Network IO descriptor to a specific port */
78 int dev_c2691_nm_4t_unset_nio(c2691_t *router,u_int nm_bay,u_int port_id)
79 {
80 struct mueslix_data *d;
81
82 if ((port_id >= MUESLIX_NR_CHANNELS) ||
83 !(d = c2691_nm_get_drvinfo(router,nm_bay)))
84 return(-1);
85
86 return(dev_mueslix_unset_nio(d,port_id));
87 }
88
89 /* NM-4T driver */
90 struct c2691_nm_driver dev_c2691_nm_4t_driver = {
91 "NM-4T", 1, 0,
92 dev_c2691_nm_4t_init,
93 dev_c2691_nm_4t_shutdown,
94 dev_c2691_nm_4t_set_nio,
95 dev_c2691_nm_4t_unset_nio,
96 NULL,
97 };

  ViewVC Help
Powered by ViewVC 1.1.26