Search
lxdream.org :: lxdream/src/cpu.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/cpu.h
changeset 1091:186558374345
prev1065:bc1cc0c54917
author nkeynes
date Fri Mar 02 23:49:10 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Android WIP:
* Rename gui_jni.c to gui_android.c - now quite android specific.
* Implement generic EGL driver with very minimal Java wrapper
* Run emulation in separate thread, and implement simple queue for
inter-thread communication.
* Add menu/action-bar items for start + reset
view annotate diff log raw
     1 /**
     2  * $Id$
     3  * 
     4  * Generic CPU definitions, primarily for providing information to the GUI.
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #ifndef lxdream_cpu_H
    20 #define lxdream_cpu_H 1
    22 #include <stdio.h>
    24 #include "lxdream.h"
    25 #include "mem.h"
    27 #ifdef __cplusplus
    28 extern "C" {
    29 #endif
    31 /**
    32  * Disassembly function pointer typedef.
    33  *
    34  * @param pc Address to disassemble
    35  * @param buffer String buffer to write disassembly into
    36  * @param buflen Maximum length of buffer
    37  * @return next address to disassemble
    38  */
    39 typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );
    41 #define REG_TYPE_INT 0
    42 #define REG_TYPE_FLOAT 1
    43 #define REG_TYPE_DOUBLE 2
    44 #define REG_TYPE_NONE 3 /* Used for empty/separator field */
    46 /**
    47  * Structure that defines a single register in a CPU for display purposes.
    48  */
    49 typedef struct reg_desc_struct {
    50     char *name;
    51     int type;
    52     void *value;
    53 } reg_desc_t;
    55 /**
    56  * CPU definition structure - basic information and support functions. Most
    57  * of this is for debugger use.
    58  */
    59 typedef struct cpu_desc_struct {
    60     char *name; /* CPU Name */
    61     /**
    62      * Single instruction disassembly 
    63      **/
    64     disasm_func_t disasm_func;
    66     /**
    67      * Return a pointer to a register (indexed per the reg_desc table)
    68      */
    69     void * (*get_register)( int reg );
    70     gboolean (*is_valid_page_func)(uint32_t); /* Test for valid memory page */
    71     /* Access to memory addressed by the CPU - physical and virtual versions.
    72      * Virtual access should account for the current CPU mode, privilege level,
    73      * etc.
    74      * All functions return the number of bytes copied, which may be 0 if the
    75      * address is unmapped.
    76      */
    77     size_t (*read_mem_phys)(unsigned char *buf, uint32_t addr, size_t length);
    78     size_t (*write_mem_phys)(uint32_t addr, unsigned char *buf, size_t length);
    79     size_t (*read_mem_vma)(unsigned char *buf, uint32_t addr, size_t length);
    80     size_t (*write_mem_vma)(uint32_t addr, unsigned char *buf, size_t length);
    81     gboolean (*step_func)(); /* Single step function */
    82     void (*set_breakpoint)(uint32_t, breakpoint_type_t);
    83     gboolean (*clear_breakpoint)(uint32_t, breakpoint_type_t);
    84     int (*get_breakpoint)(uint32_t);
    85     size_t instr_size; /* Size of instruction */
    86     char *regs; /* Pointer to start of registers */
    87     size_t regs_size; /* Size of register structure in bytes */
    88     const struct reg_desc_struct *regs_info; /* Description of all registers */
    89     unsigned int num_gpr_regs; /* Number of general purpose registers */
    90     unsigned int num_gdb_regs; /* Total number of registers visible to gdb */
    91     uint32_t *pc; /* Pointer to PC register */
    92 } const *cpu_desc_t;
    94 #ifdef __cplusplus
    95 }
    96 #endif
    98 gboolean gdb_init_server( const char *interface, int port, cpu_desc_t cpu, gboolean mmu );
    99 void cpu_print_registers( FILE *out, cpu_desc_t cpu );
   101 #endif /* !lxdream_cpu_H */
.