Index: Makefile.target
===================================================================
--- Makefile.target	(révision 5185)
+++ Makefile.target	(copie de travail)
@@ -211,7 +211,7 @@
 endif
 
 ifeq ($(TARGET_BASE_ARCH), alpha)
-LIBOBJS+= alpha_palcode.o
+LIBOBJS+= alpha_palcode.o alpha_es40.o
 endif
 
 ifeq ($(TARGET_BASE_ARCH), cris)
Index: target-alpha/cpu.h
===================================================================
--- target-alpha/cpu.h	(révision 5185)
+++ target-alpha/cpu.h	(copie de travail)
@@ -223,6 +223,8 @@
     IPR_LAST,
 };
 
+typedef struct alpha_def_t alpha_def_t;
+
 typedef struct CPUAlphaState CPUAlphaState;
 
 typedef struct pal_handler_t pal_handler_t;
@@ -297,6 +299,7 @@
 #define cpu_exec cpu_alpha_exec
 #define cpu_gen_code cpu_alpha_gen_code
 #define cpu_signal_handler cpu_alpha_signal_handler
+#define cpu_list alpha_cpu_list
 
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
@@ -401,6 +404,7 @@
 };
 
 CPUAlphaState * cpu_alpha_init (const char *cpu_model);
+void alpha_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 int cpu_alpha_exec(CPUAlphaState *s);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
Index: target-alpha/translate.c
===================================================================
--- target-alpha/translate.c	(révision 5185)
+++ target-alpha/translate.c	(copie de travail)
@@ -2001,17 +2001,34 @@
     gen_intermediate_code_internal(env, tb, 1);
 }
 
+#include "translate_init.c"
+
 CPUAlphaState * cpu_alpha_init (const char *cpu_model)
 {
     CPUAlphaState *env;
-    uint64_t hwpcb;
+    const alpha_def_t *def;
 
+    def = cpu_alpha_find_by_name(cpu_model);
+    if (!def)
+        return NULL;
     env = qemu_mallocz(sizeof(CPUAlphaState));
     if (!env)
         return NULL;
+    //env->cpu_model = def;
+ 
     cpu_exec_init(env);
+    //env->cpu_model_str = cpu_model;
+    cpu_reset(env);
+    return env;
+}
+
+void cpu_reset (CPUAlphaState *env)
+{
+    uint64_t hwpcb;
+
     alpha_translate_init();
     tlb_flush(env, 1);
+    
     /* XXX: should not be hardcoded */
     env->implver = IMPLVER_2106x;
     env->ps = 0x1F00;
@@ -2037,8 +2054,6 @@
     //    env->ipr[IPR_PTBR] = ldq_raw(hwpcb + 32);
     env->ipr[IPR_SISR] = 0;
     env->ipr[IPR_VIRBND] = -1ULL;
-
-    return env;
 }
 
 void gen_pc_load(CPUState *env, TranslationBlock *tb,
Index: monitor.c
===================================================================
--- monitor.c	(révision 5185)
+++ monitor.c	(copie de travail)
@@ -319,6 +319,8 @@
         term_printf(" pc=0x" TARGET_FMT_lx " npc=0x" TARGET_FMT_lx, env->pc, env->npc);
 #elif defined(TARGET_MIPS)
         term_printf(" PC=0x" TARGET_FMT_lx, env->active_tc.PC);
+#elif defined(TARGET_ALPHA)
+        term_printf(" pc=0x" TARGET_FMT_lx, env->pc);
 #endif
         if (env->halted)
             term_printf(" (halted)");
Index: configure
===================================================================
--- configure	(révision 5185)
+++ configure	(copie de travail)
@@ -565,6 +565,7 @@
         target_list="\
 i386-softmmu \
 x86_64-softmmu \
+alpha-softmmu \
 arm-softmmu \
 cris-softmmu \
 m68k-softmmu \
Index: sysemu.h
===================================================================
--- sysemu.h	(révision 5185)
+++ sysemu.h	(copie de travail)
@@ -110,6 +110,8 @@
 #define BIOS_SIZE ((512 + 32) * 1024)
 #elif defined(TARGET_MIPS)
 #define BIOS_SIZE (4 * 1024 * 1024)
+#elif defined(TARGET_ALPHA)
+#define BIOS_SIZE (2 * 1024 * 1024)
 #endif
 
 typedef enum {
Index: hw/boards.h
===================================================================
--- hw/boards.h	(révision 5185)
+++ hw/boards.h	(copie de travail)
@@ -26,6 +26,9 @@
 /* Axis ETRAX.  */
 extern QEMUMachine bareetraxfs_machine;
 
+/* es40.c */
+extern QEMUMachine es40_machine;
+
 /* pc.c */
 extern QEMUMachine pc_machine;
 extern QEMUMachine isapc_machine;
Index: hw/alpha_palcode.c
===================================================================
--- hw/alpha_palcode.c	(révision 5185)
+++ hw/alpha_palcode.c	(copie de travail)
@@ -22,7 +22,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include "qemu.h"
 #include "cpu.h"
 #include "exec-all.h"
 
--- /dev/null	2008-09-04 11:47:02.280381000 +0200
+++ target-alpha/translate_init.c	2008-06-12 15:39:18.000000000 +0200
@@ -0,0 +1,39 @@
+struct alpha_def_t {
+    const char *name;
+};
+
+/*****************************************************************************/
+/* Alpha CPU definitions */
+static alpha_def_t alpha_defs[] =
+{
+    {
+        .name = "ev68cb",
+    },
+};
+
+static const alpha_def_t *cpu_alpha_find_by_name (const char *name)
+{
+    int i;
+
+    for (i = 0; i < sizeof(alpha_defs) / sizeof(alpha_defs[0]); i++) {
+        if (strcasecmp(name, alpha_defs[i].name) == 0) {
+            return &alpha_defs[i];
+        }
+    }
+    return NULL;
+}
+
+void alpha_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+{
+    int i;
+
+    for (i = 0; i < sizeof(alpha_defs) / sizeof(alpha_defs[0]); i++) {
+        (*cpu_fprintf)(f, "Alpha '%s'\n",
+                       alpha_defs[i].name);
+    }
+}
+
+static int cpu_alpha_register (CPUAlphaState *env, const alpha_def_t *def)
+{
+    return 0;
+}
--- /dev/null	2008-09-04 11:47:02.280381000 +0200
+++ target-alpha/machine.c	2008-06-10 01:14:19.000000000 +0200
@@ -0,0 +1,28 @@
+#include "hw/hw.h"
+#include "hw/boards.h"
+
+void register_machines(void)
+{
+    qemu_register_machine(&es40_machine);
+}
+
+void cpu_save(QEMUFile *f, void *opaque)
+{
+}
+
+int cpu_load(QEMUFile *f, void *opaque, int version_id)
+{
+    return 0;
+}
+
+void DMA_run(void)
+{
+}
+
+void irq_info(void)
+{
+}
+
+void pic_info(void)
+{
+}
--- /dev/null	2008-09-04 11:47:02.280381000 +0200
+++ hw/alpha_es40.c	2008-06-12 12:33:03.000000000 +0200
@@ -0,0 +1,111 @@
+/*
+ * QEMU HP Alpha ES40 support
+ *
+ * Copyright (c) 2008 Herve Poussineau
+ *
+ * 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.h"
+#include "pc.h"
+#include "sysemu.h"
+#include "boards.h"
+
+static void main_cpu_reset(void *opaque)
+{
+    CPUState *env = opaque;
+    cpu_reset(env);
+}
+
+#define BIOS_FILENAME "es40.rom"
+#define ES40_BIOS_SIZE (2 * 1024 * 1024)
+
+static
+void es40_init (ram_addr_t ram_size, int vga_ram_size,
+                const char *boot_device, DisplayState *ds,
+                const char *kernel_filename, const char *kernel_cmdline,
+                const char *initrd_filename, const char *cpu_model)
+{
+    char buf[1024];
+    unsigned long bios_offset;
+    int bios_size;
+    CPUState *env;
+
+    /* init CPUs */
+    if (cpu_model == NULL) {
+        cpu_model = "ev68cb";
+    }
+    env = cpu_init(cpu_model);
+    if (!env) {
+        fprintf(stderr, "Unable to find CPU definition\n");
+        exit(1);
+    }
+    //register_savevm("cpu", 0, 1, cpu_save, cpu_load, env);
+    qemu_register_reset(main_cpu_reset, env);
+
+    /* allocate RAM */
+    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
+
+    /* load the BIOS image. */
+    bios_offset = ram_size + vga_ram_size;
+    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+    bios_size = load_image(buf, phys_ram_base + bios_offset);
+    if (bios_size < 0 || bios_size >= ES40_BIOS_SIZE) {
+        fprintf(stderr, "qemu: Could not load HP ES40 firmware '%s'\n",
+                buf);
+        exit(1);
+    }
+
+    cpu_register_physical_memory(0,
+                                 ES40_BIOS_SIZE, bios_offset | IO_MEM_ROM);
+
+    /* Chipset */
+    /* FIXME: at pci 0.7 */
+
+    /* Video card */
+    /* FIXME: VGA */
+
+    /* Network adapter */
+    /* FIXME: dec21143 */
+
+    /* SCSI controller */
+    /* FIXME: 53c8x */
+
+    /* IDE controller */
+    /* FIXME: at pci 0.15 */
+
+    /* USB controller */
+    /* FIXME: at pci 0.19 */
+
+    /* Real time clock */
+
+    /* Serial ports */
+    /* FIXME: 2 serial ports? */
+
+    /* Parallel port */
+
+    /* FIXME: flash? */
+}
+
+QEMUMachine es40_machine = {
+    "es40",
+    "HP AlphaServer ES 40",
+    es40_init,
+    VGA_RAM_SIZE + ES40_BIOS_SIZE,
+};
