1 1.1 christos /* Handle 0x900000xx addresses in the sim. 2 1.1 christos 3 1.1.1.6 christos Copyright (C) 2004-2024 Free Software Foundation, Inc. 4 1.1 christos Contributed by Axis Communications. 5 1.1 christos 6 1.1 christos This file is part of the GNU simulators. 7 1.1 christos 8 1.1 christos This program is free software; you can redistribute it and/or modify 9 1.1 christos it under the terms of the GNU General Public License as published by 10 1.1 christos the Free Software Foundation; either version 3 of the License, or 11 1.1 christos (at your option) any later version. 12 1.1 christos 13 1.1 christos This program is distributed in the hope that it will be useful, 14 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 15 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 1.1 christos GNU General Public License for more details. 17 1.1 christos 18 1.1 christos You should have received a copy of the GNU General Public License 19 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 20 1.1 christos 21 1.1.1.5 christos /* This must come before any other includes. */ 22 1.1.1.5 christos #include "defs.h" 23 1.1.1.5 christos 24 1.1 christos #include "sim-main.h" 25 1.1 christos #include "hw-main.h" 26 1.1 christos 27 1.1 christos struct cris_900000xx_hw 28 1.1 christos { 29 1.1 christos }; 30 1.1 christos 31 1.1 christos static unsigned 32 1.1 christos cris_io_write_buffer (struct hw *me, const void *source, 33 1.1 christos int space, address_word addr, unsigned nr_bytes) 34 1.1 christos { 35 1.1 christos static const unsigned char ok[] = { 4, 0, 0, 0x90}; 36 1.1 christos static const unsigned char bad[] = { 8, 0, 0, 0x90}; 37 1.1 christos SIM_CPU *cpu = hw_system_cpu (me); 38 1.1 christos SIM_DESC sd = CPU_STATE (cpu); 39 1.1 christos sim_cia cia = CPU_PC_GET (cpu); 40 1.1 christos 41 1.1 christos if (addr == 0x90000004 && memcmp (source, ok, sizeof ok) == 0) 42 1.1 christos return cris_break_13_handler (cpu, 1, 0, 0, 0, 0, 0, 0, cia); 43 1.1 christos else if (addr == 0x90000008 44 1.1 christos && memcmp (source, bad, sizeof bad) == 0) 45 1.1 christos return cris_break_13_handler (cpu, 1, 34, 0, 0, 0, 0, 0, cia); 46 1.1 christos 47 1.1 christos /* If it wasn't one of those, send an invalid-memory signal. */ 48 1.1 christos sim_core_signal (sd, cpu, cia, 0, nr_bytes, addr, 49 1.1 christos write_transfer, sim_core_unmapped_signal); 50 1.1 christos 51 1.1 christos return 0; 52 1.1 christos } 53 1.1 christos 54 1.1 christos /* Instance initializer function. */ 55 1.1 christos 56 1.1 christos static void 57 1.1 christos attach_regs (struct hw *me, struct cris_900000xx_hw *hw) 58 1.1 christos { 59 1.1 christos address_word attach_address; 60 1.1 christos int attach_space; 61 1.1 christos unsigned attach_size; 62 1.1 christos reg_property_spec reg; 63 1.1 christos 64 1.1 christos if (hw_find_property (me, "reg") == NULL) 65 1.1 christos hw_abort (me, "Missing \"reg\" property"); 66 1.1 christos 67 1.1 christos if (!hw_find_reg_array_property (me, "reg", 0, ®)) 68 1.1 christos hw_abort (me, "\"reg\" property must contain three addr/size entries"); 69 1.1 christos 70 1.1 christos hw_unit_address_to_attach_address (hw_parent (me), 71 1.1 christos ®.address, 72 1.1 christos &attach_space, &attach_address, me); 73 1.1 christos hw_unit_size_to_attach_size (hw_parent (me), ®.size, &attach_size, me); 74 1.1 christos 75 1.1 christos hw_attach_address (hw_parent (me), 76 1.1 christos 0, attach_space, attach_address, attach_size, me); 77 1.1 christos } 78 1.1 christos 79 1.1 christos static void 80 1.1 christos cris_900000xx_finish (struct hw *me) 81 1.1 christos { 82 1.1 christos struct cris_900000xx_hw *hw; 83 1.1 christos 84 1.1 christos hw = HW_ZALLOC (me, struct cris_900000xx_hw); 85 1.1 christos set_hw_data (me, hw); 86 1.1 christos set_hw_io_write_buffer (me, cris_io_write_buffer); 87 1.1 christos 88 1.1 christos attach_regs (me, hw); 89 1.1 christos } 90 1.1 christos 91 1.1 christos const struct hw_descriptor dv_cris_900000xx_descriptor[] = { 92 1.1 christos { "cris_900000xx", cris_900000xx_finish, }, 93 1.1 christos { NULL }, 94 1.1 christos }; 95