Annotation of cf/dev_c3745_pcmod.c, revision 1.1.1.1

1.1       root        1: /*  
                      2:  * Cisco router simulation platform.
                      3:  * Copyright (c) 2007 Christophe Fillot ([email protected])
                      4:  *
                      5:  * PC Modules NM (NM-NAM, NM-CIDS, ...) for c3745 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_c3745.h"
                     24: 
                     25: /* Initialize a NM PC module in the specified slot */
                     26: static int dev_c3745_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:    c3745_set_slot_eeprom(VM_C3745(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,0,
                     42:                           c3745_net_irq_for_slot_port(slot,0));
                     43: 
                     44:    /* Store device info into the router structure */
                     45:    card->drv_info = data;
                     46:    return(0);
                     47: }
                     48: 
                     49: /* Remove a NM PC module from the specified slot */
                     50: static int dev_c3745_pcmod_shutdown(vm_instance_t *vm,struct cisco_card *card)
                     51: {
                     52:    struct i8255x_data *data = card->drv_info;
                     53: 
                     54:    /* Remove the NM EEPROM */
                     55:    cisco_card_unset_eeprom(card);
                     56:    c3745_set_slot_eeprom(VM_C3745(vm),card->slot_id,NULL);
                     57: 
                     58:    /* Remove the Intel i2855x chip */
                     59:    dev_i8255x_remove(data);
                     60:    return(0);
                     61: }
                     62: 
                     63: /* Bind a Network IO descriptor */
                     64: static int dev_c3745_pcmod_set_nio(vm_instance_t *vm,struct cisco_card *card,
                     65:                                    u_int port_id,netio_desc_t *nio)
                     66: {
                     67:    struct i8255x_data *d = card->drv_info;
                     68: 
                     69:    if (!d || (port_id != 0))
                     70:       return(-1);
                     71: 
                     72:    dev_i8255x_set_nio(d,nio);
                     73:    return(0);
                     74: }
                     75: 
                     76: /* Unbind a Network IO descriptor */
                     77: static int dev_c3745_pcmod_unset_nio(vm_instance_t *vm,struct cisco_card *card,
                     78:                                      u_int port_id)
                     79: {
                     80:    struct i8255x_data *d = card->drv_info;
                     81: 
                     82:    if (!d || (port_id != 0))
                     83:       return(-1);
                     84: 
                     85:    dev_i8255x_unset_nio(d);
                     86:    return(0);
                     87: }
                     88: 
                     89: /* NM-NAM driver */
                     90: struct cisco_card_driver dev_c3745_nm_nam_driver = {
                     91:    "NM-NAM", 0, 0,
                     92:    dev_c3745_pcmod_init, 
                     93:    dev_c3745_pcmod_shutdown, 
                     94:    NULL,
                     95:    dev_c3745_pcmod_set_nio,
                     96:    dev_c3745_pcmod_unset_nio,
                     97:    NULL,
                     98: };
                     99: 
                    100: /* NM-CIDS driver */
                    101: struct cisco_card_driver dev_c3745_nm_cids_driver = {
                    102:    "NM-CIDS", 0, 0,
                    103:    dev_c3745_pcmod_init, 
                    104:    dev_c3745_pcmod_shutdown, 
                    105:    NULL,
                    106:    dev_c3745_pcmod_set_nio,
                    107:    dev_c3745_pcmod_unset_nio,
                    108:    NULL,
                    109: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.