⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vl.c.svn-base

📁 我们自己开发的一个OSEK操作系统!不知道可不可以?
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
/* * QEMU System Emulator * * Copyright (c) 2003-2008 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */// #include "hw/ppc.c"//debugger//#include "target-ppc/cpu.h"//debugger#include "hw/hw.h"#include "hw/boards.h"#include "hw/usb.h"#include "hw/pcmcia.h"#include "hw/pc.h"#include "hw/fdc.h"#include "hw/audiodev.h"#include "hw/isa.h"#include "net.h"#include "console.h"#include "sysemu.h"#include "gdbstub.h"#include "qemu-timer.h"#include "qemu-char.h"#include "block.h"#include "audio/audio.h"#include <unistd.h>#include <fcntl.h>#include <signal.h>#include <time.h>#include <errno.h>#include <sys/time.h>#include <zlib.h>#ifndef _WIN32#include <sys/times.h>#include <sys/wait.h>#include <termios.h>#include <sys/poll.h>#include <sys/mman.h>#include <sys/ioctl.h>#include <sys/socket.h>#include <netinet/in.h>#include <dirent.h>#include <netdb.h>#include <sys/select.h>#include <arpa/inet.h>#ifdef _BSD#include <sys/stat.h>#ifndef __APPLE__#include <libutil.h>#endif#elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)#include <freebsd/stdlib.h>#else#ifndef __sun__#include <linux/if.h>#include <linux/if_tun.h>#include <pty.h>#include <malloc.h>#include <linux/rtc.h>/* For the benefit of older linux systems which don't supply it,   we use a local copy of hpet.h. *//* #include <linux/hpet.h> */#include "hpet.h"#include <linux/ppdev.h>#include <linux/parport.h>#else#include <sys/stat.h>#include <sys/ethernet.h>#include <sys/sockio.h>#include <netinet/arp.h>#include <netinet/in.h>#include <netinet/in_systm.h>#include <netinet/ip.h>#include <netinet/ip_icmp.h> // must come after ip.h#include <netinet/udp.h>#include <netinet/tcp.h>#include <net/if.h>#include <syslog.h>#include <stropts.h>#endif#endif#else#include <winsock2.h>int inet_aton(const char *cp, struct in_addr *ia);#endif#if defined(CONFIG_SLIRP)#include "libslirp.h"#endif#ifdef _WIN32#include <malloc.h>#include <sys/timeb.h>#include <mmsystem.h>#define getopt_long_only getopt_long#define memalign(align, size) malloc(size)#endif#include "qemu_socket.h"#ifdef CONFIG_SDL#ifdef __APPLE__#include <SDL/SDL.h>#endif#endif /* CONFIG_SDL */#ifdef CONFIG_COCOA#undef main#define main qemu_main#endif /* CONFIG_COCOA */#include "disas.h"#include "exec-all.h"#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"#ifdef __sun__#define SMBD_COMMAND "/usr/sfw/sbin/smbd"#else#define SMBD_COMMAND "/usr/sbin/smbd"#endif//#define DEBUG_UNUSED_IOPORT//#define DEBUG_IOPORT#define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024)#ifdef TARGET_PPC#define DEFAULT_RAM_SIZE 144#else#define DEFAULT_RAM_SIZE 128#endif/* in ms */#define GUI_REFRESH_INTERVAL 30/* Max number of USB devices that can be specified on the commandline.  */#define MAX_USB_CMDLINE 8/* XXX: use a two level table to limit memory usage */#define MAX_IOPORTS 65536const char *bios_dir = CONFIG_QEMU_SHAREDIR;const char *bios_name = NULL;void *ioport_opaque[MAX_IOPORTS];IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];/* Note: drives_table[MAX_DRIVES] is a dummy block driver if none available   to store the VM snapshots */DriveInfo drives_table[MAX_DRIVES+1];int nb_drives;/* point to the block driver where the snapshots are managed */BlockDriverState *bs_snapshots;int vga_ram_size;static DisplayState display_state;int nographic;const char* keyboard_layout = NULL;int64_t ticks_per_sec;int ram_size;int pit_min_timer_count = 0;int nb_nics;NICInfo nd_table[MAX_NICS];int vm_running;int rtc_utc = 1;int rtc_start_date = -1; /* -1 means now */int cirrus_vga_enabled = 1;int vmsvga_enabled = 0;#ifdef TARGET_SPARCint graphic_width = 1024;int graphic_height = 768;int graphic_depth = 8;#elseint graphic_width = 800;int graphic_height = 600;int graphic_depth = 15;#endifint full_screen = 0;int no_frame = 0;int no_quit = 0;CharDriverState *serial_hds[MAX_SERIAL_PORTS];CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];#ifdef TARGET_I386int win2k_install_hack = 0;#endifint usb_enabled = 0;static VLANState *first_vlan;int smp_cpus = 1;const char *vnc_display;#if defined(TARGET_SPARC)#define MAX_CPUS 16#elif defined(TARGET_I386)#define MAX_CPUS 255#else#define MAX_CPUS 1#endifint acpi_enabled = 1;int fd_bootchk = 1;int no_reboot = 0;int cursor_hide = 1;int graphic_rotate = 0;int daemonize = 0;const char *option_rom[MAX_OPTION_ROMS];int nb_option_roms;int semihosting_enabled = 0;int autostart = 1;#ifdef TARGET_ARMint old_param = 0;#endifconst char *qemu_name;int alt_grab = 0;#ifdef TARGET_SPARCunsigned int nb_prom_envs = 0;const char *prom_envs[MAX_PROM_ENVS];#endifint nb_drives_opt;char drives_opt[MAX_DRIVES][1024];static CPUState *cur_cpu;static CPUState *next_cpu;static int event_pending = 1;#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)/***********************************************************//* x86 ISA bus support */target_phys_addr_t isa_mem_base = 0;PicState2 *isa_pic;static uint32_t default_ioport_readb(void *opaque, uint32_t address){#ifdef DEBUG_UNUSED_IOPORT    fprintf(stderr, "unused inb: port=0x%04x\n", address);#endif    return 0xff;}static void default_ioport_writeb(void *opaque, uint32_t address, uint32_t data){#ifdef DEBUG_UNUSED_IOPORT    fprintf(stderr, "unused outb: port=0x%04x data=0x%02x\n", address, data);#endif}/* default is to make two byte accesses */static uint32_t default_ioport_readw(void *opaque, uint32_t address){    uint32_t data;    data = ioport_read_table[0][address](ioport_opaque[address], address);    address = (address + 1) & (MAX_IOPORTS - 1);    data |= ioport_read_table[0][address](ioport_opaque[address], address) << 8;    return data;}static void default_ioport_writew(void *opaque, uint32_t address, uint32_t data){    ioport_write_table[0][address](ioport_opaque[address], address, data & 0xff);    address = (address + 1) & (MAX_IOPORTS - 1);    ioport_write_table[0][address](ioport_opaque[address], address, (data >> 8) & 0xff);}static uint32_t default_ioport_readl(void *opaque, uint32_t address){#ifdef DEBUG_UNUSED_IOPORT    fprintf(stderr, "unused inl: port=0x%04x\n", address);#endif    return 0xffffffff;}static void default_ioport_writel(void *opaque, uint32_t address, uint32_t data){#ifdef DEBUG_UNUSED_IOPORT    fprintf(stderr, "unused outl: port=0x%04x data=0x%02x\n", address, data);#endif}static void init_ioports(void){    int i;    for(i = 0; i < MAX_IOPORTS; i++) {        ioport_read_table[0][i] = default_ioport_readb;        ioport_write_table[0][i] = default_ioport_writeb;        ioport_read_table[1][i] = default_ioport_readw;        ioport_write_table[1][i] = default_ioport_writew;        ioport_read_table[2][i] = default_ioport_readl;        ioport_write_table[2][i] = default_ioport_writel;    }}/* size is the word size in byte */int register_ioport_read(int start, int length, int size,                         IOPortReadFunc *func, void *opaque){    int i, bsize;    if (size == 1) {        bsize = 0;    } else if (size == 2) {        bsize = 1;    } else if (size == 4) {        bsize = 2;    } else {        hw_error("register_ioport_read: invalid size");        return -1;    }    for(i = start; i < start + length; i += size) {        ioport_read_table[bsize][i] = func;        if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque)            hw_error("register_ioport_read: invalid opaque");        ioport_opaque[i] = opaque;    }    return 0;}/* size is the word size in byte */int register_ioport_write(int start, int length, int size,                          IOPortWriteFunc *func, void *opaque){    int i, bsize;    if (size == 1) {        bsize = 0;    } else if (size == 2) {        bsize = 1;    } else if (size == 4) {        bsize = 2;    } else {        hw_error("register_ioport_write: invalid size");        return -1;    }    for(i = start; i < start + length; i += size) {        ioport_write_table[bsize][i] = func;        if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque)            hw_error("register_ioport_write: invalid opaque");        ioport_opaque[i] = opaque;    }    return 0;}void isa_unassign_ioport(int start, int length){    int i;    for(i = start; i < start + length; i++) {        ioport_read_table[0][i] = default_ioport_readb;        ioport_read_table[1][i] = default_ioport_readw;        ioport_read_table[2][i] = default_ioport_readl;        ioport_write_table[0][i] = default_ioport_writeb;        ioport_write_table[1][i] = default_ioport_writew;        ioport_write_table[2][i] = default_ioport_writel;    }}/***********************************************************/void cpu_outb(CPUState *env, int addr, int val){#ifdef DEBUG_IOPORT    if (loglevel & CPU_LOG_IOPORT)        fprintf(logfile, "outb: %04x %02x\n", addr, val);#endif    ioport_write_table[0][addr](ioport_opaque[addr], addr, val);#ifdef USE_KQEMU    if (env)        env->last_io_time = cpu_get_time_fast();#endif}void cpu_outw(CPUState *env, int addr, int val){#ifdef DEBUG_IOPORT    if (loglevel & CPU_LOG_IOPORT)        fprintf(logfile, "outw: %04x %04x\n", addr, val);#endif    ioport_write_table[1][addr](ioport_opaque[addr], addr, val);#ifdef USE_KQEMU    if (env)        env->last_io_time = cpu_get_time_fast();#endif}void cpu_outl(CPUState *env, int addr, int val){#ifdef DEBUG_IOPORT    if (loglevel & CPU_LOG_IOPORT)        fprintf(logfile, "outl: %04x %08x\n", addr, val);#endif    ioport_write_table[2][addr](ioport_opaque[addr], addr, val);#ifdef USE_KQEMU    if (env)        env->last_io_time = cpu_get_time_fast();#endif}int cpu_inb(CPUState *env, int addr){    int val;    val = ioport_read_table[0][addr](ioport_opaque[addr], addr);#ifdef DEBUG_IOPORT    if (loglevel & CPU_LOG_IOPORT)        fprintf(logfile, "inb : %04x %02x\n", addr, val);#endif#ifdef USE_KQEMU    if (env)        env->last_io_time = cpu_get_time_fast();#endif    return val;}int cpu_inw(CPUState *env, int addr){    int val;    val = ioport_read_table[1][addr](ioport_opaque[addr], addr);#ifdef DEBUG_IOPORT    if (loglevel & CPU_LOG_IOPORT)        fprintf(logfile, "inw : %04x %04x\n", addr, val);#endif#ifdef USE_KQEMU    if (env)        env->last_io_time = cpu_get_time_fast();#endif    return val;}int cpu_inl(CPUState *env, int addr){    int val;    val = ioport_read_table[2][addr](ioport_opaque[addr], addr);#ifdef DEBUG_IOPORT    if (loglevel & CPU_LOG_IOPORT)        fprintf(logfile, "inl : %04x %08x\n", addr, val);#endif#ifdef USE_KQEMU    if (env)        env->last_io_time = cpu_get_time_fast();#endif    return val;}/***********************************************************/void hw_error(const char *fmt, ...){    va_list ap;    CPUState *env;    va_start(ap, fmt);    fprintf(stderr, "qemu: hardware error: ");    vfprintf(stderr, fmt, ap);    fprintf(stderr, "\n");    for(env = first_cpu; env != NULL; env = env->next_cpu) {        fprintf(stderr, "CPU #%d:\n", env->cpu_index);#ifdef TARGET_I386        cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU);#else        cpu_dump_state(env, stderr, fprintf, 0);#endif    }    va_end(ap);    abort();}/***********************************************************//* keyboard/mouse */static QEMUPutKBDEvent *qemu_put_kbd_event;static void *qemu_put_kbd_event_opaque;static QEMUPutMouseEntry *qemu_put_mouse_event_head;static QEMUPutMouseEntry *qemu_put_mouse_event_current;void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque){    qemu_put_kbd_event_opaque = opaque;    qemu_put_kbd_event = func;}QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,                                                void *opaque, int absolute,                                                const char *name){    QEMUPutMouseEntry *s, *cursor;    s = qemu_mallocz(sizeof(QEMUPutMouseEntry));    if (!s)        return NULL;    s->qemu_put_mouse_event = func;    s->qemu_put_mouse_event_opaque = opaque;    s->qemu_put_mouse_event_absolute = absolute;    s->qemu_put_mouse_event_name = qemu_strdup(name);    s->next = NULL;    if (!qemu_put_mouse_event_head) {        qemu_put_mouse_event_head = qemu_put_mouse_event_current = s;        return s;    }    cursor = qemu_put_mouse_event_head;    while (cursor->next != NULL)        cursor = cursor->next;    cursor->next = s;    qemu_put_mouse_event_current = s;    return s;}void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry){    QEMUPutMouseEntry *prev = NULL, *cursor;    if (!qemu_put_mouse_event_head || entry == NULL)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -