Index: ioemu/Makefile.target =================================================================== --- ioemu.orig/Makefile.target 2006-07-12 11:35:00.382868802 +0100 +++ ioemu/Makefile.target 2006-07-12 11:35:00.452860033 +0100 @@ -285,7 +285,7 @@ endif # must use static linking to avoid leaving stuff in virtual address space -VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o loader.o +VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o ifdef CONFIG_WIN32 VL_OBJS+=tap-win32.o Index: ioemu/configure =================================================================== --- ioemu.orig/configure 2006-07-12 11:35:00.383868677 +0100 +++ ioemu/configure 2006-07-12 11:35:00.453859908 +0100 @@ -75,8 +75,8 @@ bigendian="no" mingw32="no" EXESUF="" -gdbstub="yes" -slirp="yes" +gdbstub="no" +slirp="no" adlib="no" oss="no" dsound="no" @@ -727,6 +727,8 @@ if expr $target : '.*-softmmu' > /dev/null ; then target_softmmu="yes" fi +#for support 256M guest +target_softmmu="yes" target_user_only="no" if expr $target : '.*-user' > /dev/null ; then target_user_only="yes" Index: ioemu/cpu-all.h =================================================================== --- ioemu.orig/cpu-all.h 2006-07-12 11:33:54.968071470 +0100 +++ ioemu/cpu-all.h 2006-07-12 11:35:00.453859908 +0100 @@ -690,7 +690,9 @@ void page_set_flags(target_ulong start, target_ulong end, int flags); void page_unprotect_range(target_ulong data, target_ulong data_size); +#ifdef CONFIG_DM #define SINGLE_CPU_DEFINES +#endif #ifdef SINGLE_CPU_DEFINES #if defined(TARGET_I386) @@ -745,6 +747,12 @@ #endif +#else /* SINGLE_CPU_DEFINES */ + +#define CPUState CPUX86State +#define cpu_init cpu_x86_init +int main_loop(void); + #endif /* SINGLE_CPU_DEFINES */ void cpu_dump_state(CPUState *env, FILE *f, Index: ioemu/disas.h =================================================================== --- ioemu.orig/disas.h 2006-07-12 11:33:54.968071470 +0100 +++ ioemu/disas.h 2006-07-12 11:35:00.453859908 +0100 @@ -1,6 +1,7 @@ #ifndef _QEMU_DISAS_H #define _QEMU_DISAS_H +#ifndef CONFIG_DM /* Disassemble this for me please... (debugging). */ void disas(FILE *out, void *code, unsigned long size); void target_disas(FILE *out, target_ulong code, target_ulong size, int flags); @@ -17,5 +18,6 @@ const char *disas_strtab; struct syminfo *next; } *syminfos; +#endif /* !CONFIG_DM */ #endif /* _QEMU_DISAS_H */ Index: ioemu/exec-all.h =================================================================== --- ioemu.orig/exec-all.h 2006-07-12 11:33:54.968071470 +0100 +++ ioemu/exec-all.h 2006-07-12 11:35:00.454859782 +0100 @@ -509,7 +509,7 @@ extern int tb_invalidated_flag; -#if !defined(CONFIG_USER_ONLY) +#if !defined(CONFIG_USER_ONLY) && !defined(CONFIG_DM) void tlb_fill(target_ulong addr, int is_write, int is_user, void *retaddr); @@ -536,7 +536,7 @@ #endif -#if defined(CONFIG_USER_ONLY) +#if defined(CONFIG_USER_ONLY) || defined(CONFIG_DM) static inline target_ulong get_phys_addr_code(CPUState *env, target_ulong addr) { return addr; Index: ioemu/hw/pc.c =================================================================== --- ioemu.orig/hw/pc.c 2006-07-12 11:33:54.967071596 +0100 +++ ioemu/hw/pc.c 2006-07-12 11:35:00.455859657 +0100 @@ -65,6 +65,7 @@ return qemu_get_clock(vm_clock); } +#ifndef CONFIG_DM /* IRQ handling */ int cpu_get_pic_interrupt(CPUState *env) { @@ -81,6 +82,7 @@ intno = pic_read_irq(isa_pic); return intno; } +#endif /* CONFIG_DM */ static void pic_irq_request(void *opaque, int level) { @@ -394,6 +396,7 @@ /*************************************************/ +#ifndef CONFIG_DM static void putb(uint8_t **pp, int val) { uint8_t *q; @@ -540,6 +543,7 @@ float_pointer_struct[10] = -mpf_checksum(float_pointer_struct, q - float_pointer_struct); } +#endif /* !CONFIG_DM */ static const int ide_iobase[2] = { 0x1f0, 0x170 }; @@ -619,12 +623,14 @@ /* init CPUs */ for(i = 0; i < smp_cpus; i++) { env = cpu_init(); +#ifndef CONFIG_DM if (i != 0) env->hflags |= HF_HALTED_MASK; if (smp_cpus > 1) { /* XXX: enable it in all cases */ env->cpuid_features |= CPUID_APIC; } +#endif /* !CONFIG_DM */ register_savevm("cpu", i, 3, cpu_save, cpu_load, env); qemu_register_reset(main_cpu_reset, env); if (pci_enabled) { @@ -683,6 +689,7 @@ bochs_bios_init(); +#ifndef CONFIG_DM if (linux_boot) { uint8_t bootsect[512]; uint8_t old_bootsect[512]; @@ -738,6 +745,7 @@ /* loader type */ stw_raw(phys_ram_base + KERNEL_PARAMS_ADDR + 0x210, 0x01); } +#endif /* !CONFIG_DM */ if (pci_enabled) { pci_bus = i440fx_init(); @@ -776,9 +784,11 @@ isa_pic = pic_init(pic_irq_request, first_cpu); pit = pit_init(0x40, 0); pcspk_init(pit); +#ifndef CONFIG_DM if (pci_enabled) { pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic); } +#endif /* !CONFIG_DM */ for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { Index: ioemu/hw/vga_int.h =================================================================== --- ioemu.orig/hw/vga_int.h 2006-07-12 11:33:54.967071596 +0100 +++ ioemu/hw/vga_int.h 2006-07-12 11:35:00.455859657 +0100 @@ -28,7 +28,7 @@ #define ST01_DISP_ENABLE 0x01 /* bochs VBE support */ -#define CONFIG_BOCHS_VBE +//#define CONFIG_BOCHS_VBE #define VBE_DISPI_MAX_XRES 1024 #define VBE_DISPI_MAX_YRES 768 Index: ioemu/monitor.c =================================================================== --- ioemu.orig/monitor.c 2006-07-12 11:33:54.968071470 +0100 +++ ioemu/monitor.c 2006-07-12 11:35:00.456859532 +0100 @@ -68,6 +68,12 @@ void term_flush(void) { +#ifdef CONFIG_DM + if (term_outbuf_index > 0 && !monitor_hd) { + fwrite(term_outbuf, term_outbuf_index, 1, stderr); + term_outbuf_index = 0; + } +#endif if (term_outbuf_index > 0) { qemu_chr_write(monitor_hd, term_outbuf, term_outbuf_index); term_outbuf_index = 0; @@ -104,6 +110,7 @@ va_end(ap); } +#ifndef CONFIG_DM static int monitor_fprintf(FILE *stream, const char *fmt, ...) { va_list ap; @@ -112,6 +119,7 @@ va_end(ap); return 0; } +#endif /* !CONFIG_DM */ static int compare_cmd(const char *name, const char *list) { @@ -225,6 +233,7 @@ return mon_cpu; } +#ifndef CONFIG_DM static void do_info_registers(void) { CPUState *env; @@ -278,6 +287,7 @@ { dump_exec_info(NULL, monitor_fprintf); } +#endif /* !CONFIG_DM */ static void do_info_history (void) { @@ -375,6 +385,7 @@ cpu_set_log(mask); } +#ifndef CONFIG_DM static void do_savevm(const char *filename) { if (qemu_savevm(filename) < 0) @@ -621,6 +632,7 @@ #endif term_printf("\n"); } +#endif /* !CONFIG_DM */ static void do_sum(uint32_t start, uint32_t size) { @@ -792,6 +804,7 @@ } } +#ifndef CONFIG_DM static void do_ioport_read(int count, int format, int size, int addr, int has_index, int index) { uint32_t val; @@ -952,6 +965,7 @@ } } #endif +#endif /* !CONFIG_DM */ static void do_info_kqemu(void) { @@ -1045,6 +1059,7 @@ "filename", "save screen into PPM image 'filename'" }, { "log", "s", do_log, "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, +#ifndef CONFIG_DM { "savevm", "F", do_savevm, "filename", "save the whole virtual machine state to 'filename'" }, { "loadvm", "F", do_loadvm, @@ -1065,21 +1080,26 @@ "/fmt expr", "print expression value (use $reg for CPU register access)", }, { "i", "/ii.", do_ioport_read, "/fmt addr", "I/O port read" }, +#endif/* !CONFIG_DM */ { "sendkey", "s", do_send_key, "keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" }, +#ifndef CONFIG_DM { "system_reset", "", do_system_reset, "", "reset the system" }, { "system_powerdown", "", do_system_powerdown, "", "send system power down event" }, +#endif /* !CONFIG_DM */ { "sum", "ii", do_sum, "addr size", "compute the checksum of a memory region" }, { "usb_add", "s", do_usb_add, "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" }, { "usb_del", "s", do_usb_del, "device", "remove USB device 'bus.addr'" }, +#ifndef CONFIG_DM { "cpu", "i", do_cpu_set, "index", "set the default CPU" }, +#endif /* !CONFIG_DM */ { NULL, NULL, }, }; @@ -1090,10 +1110,12 @@ "", "show the network state" }, { "block", "", do_info_block, "", "show the block devices" }, +#ifndef CONFIG_DM { "registers", "", do_info_registers, "", "show the cpu registers" }, { "cpus", "", do_info_cpus, "", "show infos for each CPU" }, +#endif /* !CONFIG_DM */ { "history", "", do_info_history, "", "show the command line history", }, { "irq", "", irq_info, @@ -1102,6 +1124,7 @@ "", "show i8259 (PIC) state", }, { "pci", "", pci_info, "", "show PCI info", }, +#ifndef CONFIG_DM #if defined(TARGET_I386) { "tlb", "", tlb_info, "", "show virtual to physical memory mappings", }, @@ -1110,6 +1133,7 @@ #endif { "jit", "", do_info_jit, "", "show dynamic compiler info", }, +#endif /* !CONFIG_DM */ { "kqemu", "", do_info_kqemu, "", "show kqemu information", }, { "usb", "", usb_info, @@ -1123,6 +1147,7 @@ /*******************************************************************/ +#ifndef CONFIG_DM static const char *pch; static jmp_buf expr_env; @@ -1663,6 +1688,7 @@ *pp = pch; return 0; } +#endif /* !CONFIG_DM */ static int get_str(char *buf, int buf_size, const char **pp) { @@ -1729,8 +1755,10 @@ return 0; } +#ifndef CONFIG_DM static int default_fmt_format = 'x'; static int default_fmt_size = 4; +#endif /* !CONFIG_DM */ #define MAX_ARGS 16 @@ -1738,7 +1766,10 @@ { const char *p, *pstart, *typestr; char *q; - int c, nb_args, len, i, has_arg; + int c, nb_args, len, i; +#ifndef CONFIG_DM + int has_arg; +#endif /* !CONFIG_DM */ term_cmd_t *cmd; char cmdname[256]; char buf[1024]; @@ -1830,6 +1861,7 @@ args[nb_args++] = str; } break; +#ifndef CONFIG_DM case '/': { int count, format, size; @@ -1962,6 +1994,7 @@ } } break; +#endif /* !CONFIG_DM */ case '-': { int has_option; @@ -1988,6 +2021,11 @@ args[nb_args++] = (void *)has_option; } break; +#ifdef CONFIG_DM + /* TODO: add more commands we need here to support hvm device model */ + case '/': + case 'i': +#endif /* CONFIG_DM */ default: bad_type: term_printf("%s: unknown type '%c'\n", cmdname, c); @@ -2035,6 +2073,7 @@ return; } +#ifndef CONFIG_DM static void cmd_completion(const char *name, const char *list) { const char *p, *pstart; @@ -2222,6 +2261,11 @@ for(i = 0; i < nb_args; i++) qemu_free(args[i]); } +#else +void readline_find_completion(const char *cmdline) +{ +} +#endif /* !CONFIG_DM */ static int term_can_read(void *opaque) { Index: ioemu/vl.c =================================================================== --- ioemu.orig/vl.c 2006-07-12 11:33:54.967071596 +0100 +++ ioemu/vl.c 2006-07-12 11:35:00.459859156 +0100 @@ -423,12 +423,15 @@ void hw_error(const char *fmt, ...) { va_list ap; +#ifndef CONFIG_DM CPUState *env; +#endif /* !CONFIG_DM */ va_start(ap, fmt); fprintf(stderr, "qemu: hardware error: "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); +#ifndef CONFIG_DM for(env = first_cpu; env != NULL; env = env->next_cpu) { fprintf(stderr, "CPU #%d:\n", env->cpu_index); #ifdef TARGET_I386 @@ -437,6 +440,7 @@ cpu_dump_state(env, stderr, fprintf, 0); #endif } +#endif /* !CONFIG_DM */ va_end(ap); abort(); } @@ -3800,6 +3804,7 @@ return ret; } +#ifndef CONFIG_DM /***********************************************************/ /* cpu save/restore */ @@ -4234,6 +4239,25 @@ } return 0; } +#else /* CONFIG_DM */ +void cpu_save(QEMUFile *f, void *opaque) +{ +} + +int cpu_load(QEMUFile *f, void *opaque, int version_id) +{ + return 0; +} + +static void ram_save(QEMUFile *f, void *opaque) +{ +} + +static int ram_load(QEMUFile *f, void *opaque, int version_id) +{ + return 0; +} +#endif /* CONFIG_DM */ /***********************************************************/ /* machine registration */ f='#n291'>291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
/*
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Concepts and parts of this file have been contributed by Fabio Utzig,
chvprintf() added by Brent Roman.
*/
/**
* @file chprintf.c
* @brief Mini printf-like functionality.
*
* @addtogroup chprintf
* @{
*/
#include "hal.h"
#include "chprintf.h"
#include "memstreams.h"
#define MAX_FILLER 11
#define FLOAT_PRECISION 9
static char *long_to_string_with_divisor(char *p,
long num,
unsigned radix,
long divisor) {
int i;
char *q;
long l, ll;
l = num;
if (divisor == 0) {
ll = num;
} else {
ll = divisor;
}
q = p + MAX_FILLER;
do {
i = (int)(l % radix);
i += '0';
if (i > '9')
i += 'A' - '0' - 10;
*--q = i;
l /= radix;
} while ((ll /= radix) != 0);
i = (int)(p + MAX_FILLER - q);
do
*p++ = *q++;
while (--i);
return p;
}
static char *ch_ltoa(char *p, long num, unsigned radix) {
return long_to_string_with_divisor(p, num, radix, 0);
}
#if CHPRINTF_USE_FLOAT
static const long pow10[FLOAT_PRECISION] = {
10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
};
static char *ftoa(char *p, double num, unsigned long precision) {
long l;
if ((precision == 0) || (precision > FLOAT_PRECISION))
precision = FLOAT_PRECISION;
precision = pow10[precision - 1];
l = (long)num;
p = long_to_string_with_divisor(p, l, 10, 0);
*p++ = '.';
l = (long)((num - l) * precision);
return long_to_string_with_divisor(p, l, 10, precision / 10);
}
#endif
/**
* @brief System formatted output function.
* @details This function implements a minimal @p vprintf()-like functionality
* with output on a @p BaseSequentialStream.
* The general parameters format is: %[-][width|*][.precision|*][l|L]p.
* The following parameter types (p) are supported:
* - <b>x</b> hexadecimal integer.
* - <b>X</b> hexadecimal long.
* - <b>o</b> octal integer.
* - <b>O</b> octal long.
* - <b>d</b> decimal signed integer.
* - <b>D</b> decimal signed long.
* - <b>u</b> decimal unsigned integer.
* - <b>U</b> decimal unsigned long.
* - <b>c</b> character.
* - <b>s</b> string.
* .
*
* @param[in] chp pointer to a @p BaseSequentialStream implementing object
* @param[in] fmt formatting string
* @param[in] ap list of parameters
* @return The number of bytes that would have been
* written to @p chp if no stream error occurs
*
* @api
*/
int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) {
char *p, *s, c, filler;
int i, precision, width;
int n = 0;
bool is_long, left_align;
long l;
#if CHPRINTF_USE_FLOAT
float f;
char tmpbuf[2*MAX_FILLER + 1];
#else
char tmpbuf[MAX_FILLER + 1];
#endif
while (true) {
c = *fmt++;
if (c == 0)
return n;
if (c != '%') {
streamPut(chp, (uint8_t)c);
n++;
continue;
}
p = tmpbuf;
s = tmpbuf;
left_align = FALSE;
if (*fmt == '-') {
fmt++;
left_align = TRUE;
}
filler = ' ';
if (*fmt == '0') {
fmt++;
filler = '0';
}
width = 0;
while (TRUE) {
c = *fmt++;
if (c >= '0' && c <= '9')
c -= '0';
else if (c == '*')
c = va_arg(ap, int);
else
break;
width = width * 10 + c;
}
precision = 0;
if (c == '.') {
while (TRUE) {
c = *fmt++;
if (c >= '0' && c <= '9')
c -= '0';
else if (c == '*')
c = va_arg(ap, int);
else
break;
precision *= 10;
precision += c;
}
}
/* Long modifier.*/
if (c == 'l' || c == 'L') {
is_long = TRUE;
if (*fmt)
c = *fmt++;
}
else
is_long = (c >= 'A') && (c <= 'Z');
/* Command decoding.*/
switch (c) {
case 'c':
filler = ' ';
*p++ = va_arg(ap, int);
break;
case 's':
filler = ' ';
if ((s = va_arg(ap, char *)) == 0)
s = "(null)";
if (precision == 0)
precision = 32767;
for (p = s; *p && (--precision >= 0); p++)
;
break;
case 'D':
case 'd':
case 'I':
case 'i':
if (is_long)
l = va_arg(ap, long);
else
l = va_arg(ap, int);
if (l < 0) {
*p++ = '-';
l = -l;
}
p = ch_ltoa(p, l, 10);
break;
#if CHPRINTF_USE_FLOAT
case 'f':
f = (float) va_arg(ap, double);
if (f < 0) {
*p++ = '-';
f = -f;
}
p = ftoa(p, f, precision);
break;
#endif
case 'X':
case 'x':
c = 16;
goto unsigned_common;
case 'U':
case 'u':
c = 10;
goto unsigned_common;
case 'O':
case 'o':
c = 8;
unsigned_common:
if (is_long)
l = va_arg(ap, unsigned long);
else
l = va_arg(ap, unsigned int);
p = ch_ltoa(p, l, c);
break;
default:
*p++ = c;
break;
}
i = (int)(p - s);
if ((width -= i) < 0)
width = 0;
if (left_align == FALSE)
width = -width;
if (width < 0) {
if (*s == '-' && filler == '0') {
streamPut(chp, (uint8_t)*s++);
n++;
i--;
}
do {
streamPut(chp, (uint8_t)filler);
n++;
} while (++width != 0);
}
while (--i >= 0) {
streamPut(chp, (uint8_t)*s++);
n++;
}
while (width) {
streamPut(chp, (uint8_t)filler);
n++;
width--;
}
}
}
/**
* @brief System formatted output function.
* @details This function implements a minimal @p printf() like functionality
* with output on a @p BaseSequentialStream.
* The general parameters format is: %[-][width|*][.precision|*][l|L]p.
* The following parameter types (p) are supported:
* - <b>x</b> hexadecimal integer.
* - <b>X</b> hexadecimal long.
* - <b>o</b> octal integer.
* - <b>O</b> octal long.
* - <b>d</b> decimal signed integer.
* - <b>D</b> decimal signed long.
* - <b>u</b> decimal unsigned integer.
* - <b>U</b> decimal unsigned long.
* - <b>c</b> character.
* - <b>s</b> string.
* .
*
* @param[in] chp pointer to a @p BaseSequentialStream implementing object
* @param[in] fmt formatting string
*
* @api
*/
int chprintf(BaseSequentialStream *chp, const char *fmt, ...) {
va_list ap;
int formatted_bytes;
va_start(ap, fmt);
formatted_bytes = chvprintf(chp, fmt, ap);
va_end(ap);
return formatted_bytes;
}
/**
* @brief System formatted output function.
* @details This function implements a minimal @p snprintf()-like functionality.
* The general parameters format is: %[-][width|*][.precision|*][l|L]p.
* The following parameter types (p) are supported:
* - <b>x</b> hexadecimal integer.
* - <b>X</b> hexadecimal long.
* - <b>o</b> octal integer.
* - <b>O</b> octal long.
* - <b>d</b> decimal signed integer.
* - <b>D</b> decimal signed long.
* - <b>u</b> decimal unsigned integer.
* - <b>U</b> decimal unsigned long.
* - <b>c</b> character.
* - <b>s</b> string.
* .
* @post @p str is NUL-terminated, unless @p size is 0.
*
* @param[in] str pointer to a buffer
* @param[in] size maximum size of the buffer
* @param[in] fmt formatting string
* @return The number of characters (excluding the
* terminating NUL byte) that would have been
* stored in @p str if there was room.
*
* @api
*/
int chsnprintf(char *str, size_t size, const char *fmt, ...) {
va_list ap;
MemoryStream ms;
BaseSequentialStream *chp;
size_t size_wo_nul;
int retval;
if (size > 0)
size_wo_nul = size - 1;
else
size_wo_nul = 0;
/* Memory stream object to be used as a string writer, reserving one
byte for the final zero.*/
msObjectInit(&ms, (uint8_t *)str, size_wo_nul, 0);
/* Performing the print operation using the common code.*/
chp = (BaseSequentialStream *)(void *)&ms;
va_start(ap, fmt);
retval = chvprintf(chp, fmt, ap);
va_end(ap);
/* Terminate with a zero, unless size==0.*/
if (ms.eos < size)
str[ms.eos] = 0;
/* Return number of bytes that would have been written.*/
return retval;
}
/** @} */