/[dynamips]/trunk/dev_c3725_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_c3725_serial.c

Parent Directory Parent Directory | Revision Log Revision Log


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

1 dpavlin 4 /*
2 dpavlin 7 * Cisco router simulation platform.
3 dpavlin 4 * 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_c3725.h"
23    
24     /* ====================================================================== */
25     /* NM-4T */
26     /* ====================================================================== */
27    
28     /*
29     * dev_c3725_nm_4t_init()
30     *
31     * Add a NM-4T network module into specified slot.
32     */
33 dpavlin 11 int dev_c3725_nm_4t_init(vm_instance_t *vm,struct cisco_card *card)
34 dpavlin 4 {
35     struct mueslix_data *data;
36 dpavlin 11 u_int slot = card->slot_id;
37 dpavlin 4
38 dpavlin 11 /* Set the PCI bus */
39     card->pci_bus = vm->slots_pci_bus[slot];
40    
41 dpavlin 4 /* Set the EEPROM */
42 dpavlin 11 cisco_card_set_eeprom(vm,card,cisco_eeprom_find_nm("NM-4T"));
43     c3725_set_slot_eeprom(VM_C3725(vm),slot,&card->eeprom);
44 dpavlin 4
45     /* Create the Mueslix chip */
46 dpavlin 11 data = dev_mueslix_init(vm,card->dev_name,0,
47     card->pci_bus,c3725_nm_get_pci_device(slot),
48     c3725_net_irq_for_slot_port(slot,0));
49 dpavlin 4
50     if (!data) return(-1);
51    
52     /* Store device info into the router structure */
53 dpavlin 11 card->drv_info = data;
54     return(0);
55 dpavlin 4 }
56    
57     /* Remove a NM-4T from the specified slot */
58 dpavlin 11 int dev_c3725_nm_4t_shutdown(vm_instance_t *vm,struct cisco_card *card)
59 dpavlin 4 {
60 dpavlin 11 /* Remove the NM EEPROM */
61     cisco_card_unset_eeprom(card);
62     c3725_set_slot_eeprom(VM_C3725(vm),card->slot_id,NULL);
63 dpavlin 4
64 dpavlin 11 /* Remove the mueslix driver */
65     dev_mueslix_remove(card->drv_info);
66 dpavlin 4 return(0);
67     }
68    
69     /* Bind a Network IO descriptor to a specific port */
70 dpavlin 11 int dev_c3725_nm_4t_set_nio(vm_instance_t *vm,struct cisco_card *card,
71     u_int port_id,netio_desc_t *nio)
72 dpavlin 4 {
73 dpavlin 11 struct mueslix_data *d = card->drv_info;
74 dpavlin 4
75 dpavlin 11 if (!d || (port_id >= MUESLIX_NR_CHANNELS))
76 dpavlin 4 return(-1);
77    
78 dpavlin 11 return(dev_mueslix_set_nio(d,port_id,nio));
79 dpavlin 4 }
80    
81     /* Unbind a Network IO descriptor to a specific port */
82 dpavlin 11 int dev_c3725_nm_4t_unset_nio(vm_instance_t *vm,struct cisco_card *card,
83     u_int port_id)
84 dpavlin 4 {
85 dpavlin 11 struct mueslix_data *d = card->drv_info;
86 dpavlin 4
87 dpavlin 11 if (!d || (port_id >= MUESLIX_NR_CHANNELS))
88 dpavlin 4 return(-1);
89    
90     return(dev_mueslix_unset_nio(d,port_id));
91     }
92    
93     /* NM-4T driver */
94 dpavlin 11 struct cisco_card_driver dev_c3725_nm_4t_driver = {
95 dpavlin 4 "NM-4T", 1, 0,
96     dev_c3725_nm_4t_init,
97     dev_c3725_nm_4t_shutdown,
98 dpavlin 11 NULL,
99 dpavlin 4 dev_c3725_nm_4t_set_nio,
100     dev_c3725_nm_4t_unset_nio,
101     NULL,
102     };

  ViewVC Help
Powered by ViewVC 1.1.26