Search
lxdream.org :: lxdream/src/cpu.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/cpu.h
changeset 1065:bc1cc0c54917
prev998:1754a8c6a9cf
prev566:59be465e5f01
next1091:186558374345
author nkeynes
date Sun Jul 05 13:52:50 2009 +1000 (12 years ago)
permissions -rw-r--r--
last change No-op merge lxdream-mmu to remove head (actually merged long ago)
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 "lxdream.h"
    23 #include "mem.h"
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    29 /**
    30  * Disassembly function pointer typedef.
    31  *
    32  * @param pc Address to disassemble
    33  * @param buffer String buffer to write disassembly into
    34  * @param buflen Maximum length of buffer
    35  * @return next address to disassemble
    36  */
    37 typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );
    39 #define REG_INT 0
    40 #define REG_FLOAT 1
    41 #define REG_DOUBLE 2
    42 #define REG_NONE 3 /* Used for empty/separator field */
    44 /**
    45  * Structure that defines a single register in a CPU for display purposes.
    46  */
    47 typedef struct reg_desc_struct {
    48     char *name;
    49     int type;
    50     void *value;
    51 } reg_desc_t;
    53 /**
    54  * CPU definition structure - basic information and support functions. Most
    55  * of this is for debugger use.
    56  */
    57 typedef struct cpu_desc_struct {
    58     char *name; /* CPU Name */
    59     /**
    60      * Single instruction disassembly 
    61      **/
    62     disasm_func_t disasm_func;
    64     /**
    65      * Return a pointer to a register (indexed per the reg_desc table)
    66      */
    67     void * (*get_register)( int reg );
    68     gboolean (*is_valid_page_func)(uint32_t); /* Test for valid memory page */
    69     /* Access to memory addressed by the CPU - physical and virtual versions.
    70      * Virtual access should account for the current CPU mode, privilege level,
    71      * etc.
    72      * All functions return the number of bytes copied, which may be 0 if the
    73      * address is unmapped.
    74      */
    75     size_t (*read_mem_phys)(unsigned char *buf, uint32_t addr, size_t length);
    76     size_t (*write_mem_phys)(uint32_t addr, unsigned char *buf, size_t length);
    77     size_t (*read_mem_vma)(unsigned char *buf, uint32_t addr, size_t length);
    78     size_t (*write_mem_vma)(uint32_t addr, unsigned char *buf, size_t length);
    79     gboolean (*step_func)(); /* Single step function */
    80     void (*set_breakpoint)(uint32_t, breakpoint_type_t);
    81     gboolean (*clear_breakpoint)(uint32_t, breakpoint_type_t);
    82     int (*get_breakpoint)(uint32_t);
    83     size_t instr_size; /* Size of instruction */
    84     char *regs; /* Pointer to start of registers */
    85     size_t regs_size; /* Size of register structure in bytes */
    86     const struct reg_desc_struct *regs_info; /* Description of all registers */
    87     unsigned int num_gpr_regs; /* Number of general purpose registers */
    88     unsigned int num_gdb_regs; /* Total number of registers visible to gdb */
    89     uint32_t *pc; /* Pointer to PC register */
    90 } const *cpu_desc_t;
    92 #ifdef __cplusplus
    93 }
    94 #endif
    96 gboolean gdb_init_server( const char *interface, int port, cpu_desc_t cpu, gboolean mmu );
    98 #endif /* !lxdream_cpu_H */
.