Annotation of cf/hv_c3725.c, revision 1.1.1.3

1.1       root        1: /*
                      2:  * Cisco 3725 simulation platform.
                      3:  * Copyright (c) 2006 Christophe Fillot ([email protected])
                      4:  *
                      5:  * Hypervisor C3725 routines.
                      6:  */
                      7: 
                      8: #include <stdio.h>
                      9: #include <stdlib.h>
                     10: #include <unistd.h>
                     11: #include <string.h>
                     12: #include <sys/types.h>
                     13: #include <sys/stat.h>
                     14: #include <sys/mman.h>
                     15: #include <signal.h>
                     16: #include <fcntl.h>
                     17: #include <errno.h>
                     18: #include <assert.h>
                     19: #include <stdarg.h>
                     20: #include <sys/ioctl.h>
                     21: #include <sys/types.h>
                     22: #include <sys/socket.h>
                     23: #include <arpa/inet.h>
                     24: #include <pthread.h>
                     25: 
1.1.1.2   root       26: #include "cpu.h"
                     27: #include "vm.h"
1.1       root       28: #include "device.h"
                     29: #include "dev_c3725.h"
                     30: #include "dev_vtty.h"
                     31: #include "utils.h"
                     32: #include "net.h"
                     33: #include "atm.h"
                     34: #include "frame_relay.h"
                     35: #include "crc.h"
                     36: #include "net_io.h"
                     37: #include "net_io_bridge.h"
                     38: #ifdef GEN_ETH
                     39: #include "gen_eth.h"
                     40: #endif
                     41: #include "registry.h"
                     42: #include "hypervisor.h"
                     43: 
                     44: /* Set the I/O mem size */
                     45: static int cmd_set_iomem(hypervisor_conn_t *conn,int argc,char *argv[])
                     46: {
                     47:    vm_instance_t *vm;
                     48: 
1.1.1.3 ! root       49:    if (!(vm = hypervisor_find_vm(conn,argv[0])))
1.1       root       50:       return(-1);
                     51: 
1.1.1.3 ! root       52:    vm->nm_iomem_size = 0x8000 | atoi(argv[1]);
1.1       root       53: 
                     54:    vm_release(vm);
                     55:    hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
                     56:    return(0);
                     57: }
                     58: 
                     59: /* Set the base MAC address for the chassis */
                     60: static int cmd_set_mac_addr(hypervisor_conn_t *conn,int argc,char *argv[])
                     61: {
                     62:    vm_instance_t *vm;
                     63: 
1.1.1.3 ! root       64:    if (!(vm = hypervisor_find_vm(conn,argv[0])))
1.1       root       65:       return(-1);
                     66: 
                     67:    if ((c3725_chassis_set_mac_addr(VM_C3725(vm),argv[1])) == -1) {
                     68:       vm_release(vm);
                     69:       hypervisor_send_reply(conn,HSC_ERR_CREATE,1,
                     70:                             "unable to set MAC address for router '%s'",
                     71:                             argv[0]);
                     72:       return(-1);
                     73:    }
                     74: 
                     75:    vm_release(vm);
                     76:    hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
                     77:    return(0);
                     78: }
                     79: 
                     80: /* Show C3725 hardware */
                     81: static int cmd_show_hardware(hypervisor_conn_t *conn,int argc,char *argv[])
                     82: {
                     83:    vm_instance_t *vm;
                     84:    c3725_t *router;
                     85: 
1.1.1.3 ! root       86:    if (!(vm = hypervisor_find_vm(conn,argv[0])))
1.1       root       87:       return(-1);
                     88: 
                     89:    router = VM_C3725(vm);
                     90:    c3725_show_hardware(router);
                     91: 
                     92:    vm_release(vm);
                     93:    hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
                     94:    return(0);
                     95: }
                     96: 
                     97: /* Show info about C3725 object */
                     98: static void cmd_show_c3725_list(registry_entry_t *entry,void *opt,int *err)
                     99: {
                    100:    hypervisor_conn_t *conn = opt;
                    101:    vm_instance_t *vm = entry->data;
                    102: 
1.1.1.3 ! root      103:    if (vm->platform == conn->cur_module->opt)
1.1       root      104:       hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%s",entry->name);
                    105: }
                    106: 
                    107: /* C3725 List */
                    108: static int cmd_c3725_list(hypervisor_conn_t *conn,int argc,char *argv[])
                    109: {
                    110:    int err = 0;
                    111:    registry_foreach_type(OBJ_TYPE_VM,cmd_show_c3725_list,conn,&err);
                    112:    hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
                    113:    return(0);
                    114: }
                    115: 
                    116: /* C3725 commands */
                    117: static hypervisor_cmd_t c3725_cmd_array[] = {
                    118:    { "set_iomem", 2, 2, cmd_set_iomem, NULL },
                    119:    { "set_mac_addr", 2, 2, cmd_set_mac_addr, NULL },
                    120:    { "show_hardware", 1, 1, cmd_show_hardware, NULL },
                    121:    { "list", 0, 0, cmd_c3725_list, NULL },
                    122:    { NULL, -1, -1, NULL, NULL },
                    123: };
                    124: 
                    125: /* Hypervisor C3725 initialization */
1.1.1.3 ! root      126: int hypervisor_c3725_init(vm_platform_t *platform)
1.1       root      127: {
                    128:    hypervisor_module_t *module;
                    129: 
1.1.1.3 ! root      130:    module = hypervisor_register_module(platform->name,platform);
1.1       root      131:    assert(module != NULL);
                    132: 
                    133:    hypervisor_register_cmd_array(module,c3725_cmd_array);
                    134:    return(0);
                    135: }

unix.superglobalmegacorp.com

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