void goldfish_timer_and_rtc_init(uint32_t timerbase, int timerirq)
{
    timer_state.dev.base = timerbase;
    timer_state.dev.irq = timerirq;
    timer_state.timer = qemu_new_timer(vm_clock, goldfish_timer_tick, &timer_state);
    goldfish_device_add(&timer_state.dev, goldfish_timer_readfn, goldfish_timer_writefn, &timer_state);
    register_savevm( "goldfish_timer", 0, GOLDFISH_TIMER_SAVE_VERSION,
                     goldfish_timer_save, goldfish_timer_load, &timer_state);

    goldfish_device_add(&rtc_state.dev, goldfish_rtc_readfn, goldfish_rtc_writefn, &rtc_state);
    register_savevm( "goldfish_rtc", 0, GOLDFISH_RTC_SAVE_VERSION,
                     goldfish_rtc_save, goldfish_rtc_load, &rtc_state);
}
Exemple #2
0
int goldfish_device_bus_init(uint32_t base, uint32_t irq)
{
    bus_state.dev.base = base;
    bus_state.dev.irq = irq;

    return goldfish_device_add(&bus_state.dev, goldfish_bus_readfn, goldfish_bus_writefn, &bus_state);
}
qemu_irq*  goldfish_interrupt_init(uint32_t base, qemu_irq parent_irq, qemu_irq parent_fiq)
{
    int ret;
    struct goldfish_int_state *s;
    qemu_irq*  qi;

    s = qemu_mallocz(sizeof(*s));
    qi = qemu_allocate_irqs(goldfish_int_set_irq, s, GFD_MAX_IRQ);
    s->dev.name = "goldfish_interrupt_controller";
    s->dev.id = -1;
    s->dev.base = base;
    s->dev.size = 0x1000;
    s->parent_irq = parent_irq;
    s->parent_fiq = parent_fiq;

    ret = goldfish_device_add(&s->dev, goldfish_int_readfn, goldfish_int_writefn, s);
    if(ret) {
        qemu_free(s);
        return NULL;
    }

    register_savevm( "goldfish_int", 0, GOLDFISH_INT_SAVE_VERSION,
                     goldfish_int_save, goldfish_int_load, s);

    return qi;
}
void *goldfish_switch_add(char *name, uint32_t (*writefn)(void *opaque, uint32_t state), void *writeopaque, int id)
{
    int ret;
    struct switch_state *s;

    s = qemu_mallocz(sizeof(*s));
    s->dev.name = "goldfish-switch";
    s->dev.id = id;
    s->dev.size = 0x1000;
    s->dev.irq_count = 1;
    s->name = name;
    s->writefn = writefn;
    s->writeopaque = writeopaque;


    ret = goldfish_device_add(&s->dev, goldfish_switch_readfn, goldfish_switch_writefn, s);
    if(ret) {
        qemu_free(s);
        return NULL;
    }

    register_savevm( "goldfish_switch", 0, GOLDFISH_SWITCH_SAVE_VERSION,
                     goldfish_switch_save, goldfish_switch_load, s);

    return s;
}
Exemple #5
0
int goldfish_tty_add(CharDriverState *cs, int id, uint32_t base, int irq)
{
    int ret;
    struct tty_state *s;
    static int  instance_id = 0;

    s = g_malloc0(sizeof(*s));
    s->dev.name = "goldfish_tty";
    s->dev.id = id;
    s->dev.base = base;
    s->dev.size = 0x1000;
    s->dev.irq = irq;
    s->dev.irq_count = 1;
    s->cs = cs;

    if(cs) {
        qemu_chr_add_handlers(cs, tty_can_receive, tty_receive, NULL, s);
    }

    ret = goldfish_device_add(&s->dev, goldfish_tty_readfn, goldfish_tty_writefn, s);
    if(ret) {
        g_free(s);
    } else {
        register_savevm( "goldfish_tty", instance_id++, GOLDFISH_TTY_SAVE_VERSION,
                         goldfish_tty_save, goldfish_tty_load, s);
    }
    return ret;
}
void pipe_dev_init()
{
    PipeDevice *s;

    s = (PipeDevice *) qemu_mallocz(sizeof(*s));

    s->dev.name = "qemu_pipe";
    s->dev.id = -1;
    s->dev.base = 0;       
    s->dev.size = 0x2000;
    s->dev.irq = 0;
    s->dev.irq_count = 1;

    goldfish_device_add(&s->dev, pipe_dev_readfn, pipe_dev_writefn, s);

    register_savevm( "goldfish_pipe", 0, GOLDFISH_PIPE_SAVE_VERSION,
                      goldfish_pipe_save, goldfish_pipe_load, s);

#if DEBUG_ZERO_PIPE
    goldfish_pipe_add_type("zero", NULL, &zeroPipe_funcs);
#endif
#if DEBUG_PINGPONG_PIPE
    goldfish_pipe_add_type("pingpong", NULL, &pingPongPipe_funcs);
#endif
#if DEBUG_THROTTLE_PIPE
    goldfish_pipe_add_type("throttle", NULL, &throttlePipe_funcs);
#endif
}
static int goldfish_busdev_init(DeviceState *qdev, DeviceInfo *qinfo)
{
    GoldfishDeviceInfo *info = (GoldfishDeviceInfo *)qinfo;
    GoldfishDevice *dev = DO_UPCAST(GoldfishDevice, qdev, qdev);
    int ret = info->init(dev);
    if (ret == 0) {
        goldfish_device_add(dev, info->readfn, info->writefn, dev);
    }
    return ret;
}
/* initialize the trace device */
void trace_dev_init()
{
    trace_dev_state *s;

    s = (trace_dev_state *)qemu_mallocz(sizeof(trace_dev_state));
    s->dev.name = "qemu_trace";
    s->dev.id = -1;
    s->dev.base = 0;       // will be allocated dynamically
    s->dev.size = 0x2000;
    s->dev.irq = 0;
    s->dev.irq_count = 0;

    goldfish_device_add(&s->dev, trace_dev_readfn, trace_dev_writefn, s);

    exec_path[0] = exec_arg[0] = '\0';
}
Exemple #9
0
void goldfish_leds_init(uint32_t base)
{
    struct goldfish_leds_state *s;

    s = (struct goldfish_leds_state *)qemu_mallocz(sizeof(*s));
    s->dev.name = "goldfish_leds";
    s->dev.id = 0;
    s->dev.base = base;
    s->dev.size = 0x1000;
    s->dev.irq_count = 0;

    goldfish_device_add(&s->dev, leds_readfn, leds_writefn, s);

#ifdef CONFIG_VPMU
    GlobalVPMU.adev_stat_ptr->lcd_brightness = &(s->brightness);
#endif
}
Exemple #10
0
void
goldfish_nfc_init()
{
    struct nfc_state* s = &_nfc_states[0];

    nfc_device_init(&s->nfc);

    s->dev.name = "goldfish_nfc";
    s->dev.base = 0;  /* allocated dynamically. */
    s->dev.size = 4096; /* overall size of I/O buffers */
    s->dev.irq = 0; /* allocated dynamically */
    s->dev.irq_count = 1;

    goldfish_device_add(&s->dev, goldfish_nfc_readfn,
                        goldfish_nfc_writefn, s);

    register_savevm("nfc_state", 0, NCIDEV_STATE_SAVE_VERSION,
                    goldfish_nfc_save, goldfish_nfc_load, s);
}
GoldfishBus *goldfish_bus_init(uint32_t base, uint32_t irq)
{
    GoldfishBus *bus;
    BusState *qbus;
    DeviceState *dev;

    dev = qdev_create(NULL, "goldfish_bridge");
    qdev_init_nofail(dev);

    qbus = qbus_create(&goldfish_bus_info, dev, "goldfish_bus");
    bus = DO_UPCAST(GoldfishBus, bus, qbus);

    dev = goldfish_device_bus_create(bus, base, irq);
    GoldfishDevice *gdev = DO_UPCAST(GoldfishDevice, qdev, dev);
    bus->dev = *gdev;

    goldfish_device_add(&bus->dev, goldfish_device_bus_readfn, goldfish_device_bus_writefn, bus);

    return bus;
}
void
goldfish_rfkill_init()
{
    struct rfkill_state *s = &_rfkill_states[0];

    s->dev.name = "goldfish_rfkill";
    s->dev.base = 0;  /* Will be allocated dynamically. */
    s->dev.size = 0x1000;
    s->dev.irq_count = 1;

    s->int_mask = 0;
    s->inta = 0;
    s->hw_block = 0;
    s->blocking = 0;

    goldfish_device_add(&s->dev, goldfish_rfkill_readfn, goldfish_rfkill_writefn, s);

    register_savevm( "rfkill_state", 0, RFKILL_STATE_SAVE_VERSION,
                     goldfish_rfkill_save, goldfish_rfkill_load, s);
}
Exemple #13
0
void goldfish_sensor_init()
{
    struct goldfish_sensor_state *s;

    s = (struct goldfish_sensor_state *)qemu_mallocz(sizeof(*s));
    s->dev.name = "goldfish_sensor";
    s->dev.base = 0;    // will be allocated dynamically
    s->dev.size = 0x1000;
    s->dev.irq_count = 1;

    // default values for the sensor
    s->int_enable = 0;
    s->int_status = 0;

    sensor_state = s;

    goldfish_device_add(&s->dev, goldfish_sensor_readfn, goldfish_sensor_writefn, s);

    register_savevm( "sensor_state", 0, SENSOR_STATE_SAVE_VERSION,
                     goldfish_sensor_save, goldfish_sensor_load, s);
}
void init_goldfish_pic(){
	static skyeye_class_t goldfish_pic_class = {
		.class_name = "goldfish_pic",
		.class_desc = "goldfish pic",
		.new_instance = new_goldfish_pic_device,
		.free_instance = del_goldfish_pic_device,
		.get_attr = NULL,
		.set_attr = NULL
	};
	SKY_register_class(goldfish_pic_class.class_name,&goldfish_pic_class);
}
#if 0
qemu_irq*  goldfish_interrupt_init(uint32_t base, qemu_irq parent_irq, qemu_irq parent_fiq)
{
    int ret;
    struct pic_state_t *s;
    qemu_irq*  qi;

    s = qemu_mallocz(sizeof(*s));
    qi = qemu_allocate_irqs(goldfish_int_set_irq, s, 32);
    s->dev.name = "goldfish_interrupt_controller";
    s->dev.id = -1;
    s->dev.base = base;
    s->dev.size = 0x1000;
    s->parent_irq = parent_irq;
    s->parent_fiq = parent_fiq;

    ret = goldfish_device_add(&s->dev, goldfish_int_readfn, goldfish_int_writefn, s);
    if(ret) {
        qemu_free(s);
        return NULL;
    }

    register_savevm( "goldfish_int", 0, GOLDFISH_INT_SAVE_VERSION,
                     goldfish_int_save, goldfish_int_load, s);

    return qi;
}
Exemple #15
0
int goldfish_tty_add(CharDriverState *cs, int id, uint32_t base, int irq)
{
    int ret;
    struct tty_state *s;
    static int  instance_id = 0;

    if (irq && s_tty.shared_irq) {
        //printf("goldfish_tty_add: shared irq already assigned to %d\n",
        //       s_tty.shared_irq);
        return -1;
    }

    s = qemu_mallocz(sizeof(*s));
    s->dev.name = "goldfish_tty";
    s->dev.id = id;
    s->dev.base = base;
    s->dev.size = 0x1000;
    s->dev.irq = (irq ? irq : s_tty.shared_irq);
    s->dev.irq_count = 1;
    s->cs = cs;

    if(cs) {
        qemu_chr_add_handlers(cs, tty_can_receive, tty_receive, NULL, s);
    }

    ret = goldfish_device_add(&s->dev, goldfish_tty_readfn, goldfish_tty_writefn, s);
    if(ret) {
        qemu_free(s);
    } else {
        if (!s_tty.shared_irq) {
            s_tty.shared_irq = s->dev.irq;
        }
        register_savevm( "goldfish_tty", instance_id++, GOLDFISH_TTY_SAVE_VERSION,
                         goldfish_tty_save, goldfish_tty_load, s);
    }
    return ret;
}
void goldfish_battery_init(int has_battery)
{
    struct goldfish_battery_state *s;

    s = (struct goldfish_battery_state *)g_malloc0(sizeof(*s));
    s->dev.name = "goldfish-battery";
    s->dev.base = 0;    // will be allocated dynamically
    s->dev.size = 0x1000;
    s->dev.irq_count = 1;

    // default values for the battery
    s->ac_online = 1;
    s->hw_has_battery = has_battery;
    if (has_battery) {
        s->status = POWER_SUPPLY_STATUS_CHARGING;
        s->health = POWER_SUPPLY_HEALTH_GOOD;
        s->present = 1;     // battery is present
        s->capacity = 50;   // 50% charged
    } else {
        s->status = POWER_SUPPLY_STATUS_NOT_CHARGING;
        s->health = POWER_SUPPLY_HEALTH_DEAD;
        s->present = 0;
        s->capacity = 0;
    }

    battery_state = s;

    goldfish_device_add(&s->dev, goldfish_battery_readfn, goldfish_battery_writefn, s);

    register_savevm(NULL,
                    "battery_state",
                    0,
                    BATTERY_STATE_SAVE_VERSION,
                    goldfish_battery_save,
                    goldfish_battery_load,
                    s);
}
void goldfish_battery_init()
{
    struct goldfish_battery_state *s;

    s = (struct goldfish_battery_state *)qemu_mallocz(sizeof(*s));
    s->dev.name = "goldfish-battery";
    s->dev.base = 0;    
    s->dev.size = 0x1000;
    s->dev.irq_count = 1;

    
    s->ac_online = 1;
    s->status = POWER_SUPPLY_STATUS_CHARGING;
    s->health = POWER_SUPPLY_HEALTH_GOOD;
    s->present = 1;     
    s->capacity = 50;   

    battery_state = s;

    goldfish_device_add(&s->dev, goldfish_battery_readfn, goldfish_battery_writefn, s);

    register_savevm( "battery_state", 0, BATTERY_STATE_SAVE_VERSION,
                     goldfish_battery_save, goldfish_battery_load, s);
}