From 601cecf016bc104dc20b12630be28d3a73767ba6 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Fri, 20 Jun 2003 13:32:34 +0000 Subject: 2003-06-20 Andrew Cagney * sim_calls.c (sim_create_inferior): Assert that psim_write_register succeeded. (sim_fetch_register, sim_store_register): Make "regname" constant. Delete Altivec hack. Return result from psim_read_register / psim_write_register. * psim.h (psim_read_register, psim_write_register): Change return type to int. Update comments. * psim.c: Update copyright. (psim_stack): Assert that the psim_read_register worked. (psim_read_register, psim_read_register): Return the register's size. Allocate the cooked buffer dynamically. * hw_register.c: Update copyright. (do_register_init): Check that psim_write_register succeeded. * hw_init.c: Update copyright. (create_ppc_elf_stack_frame, create_ppc_aix_stack_frame): Assert that the register transfer worked. --- sim/ppc/psim.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'sim/ppc/psim.c') diff --git a/sim/ppc/psim.c b/sim/ppc/psim.c index 76bb452..1eb8e00 100644 --- a/sim/ppc/psim.c +++ b/sim/ppc/psim.c @@ -1,6 +1,6 @@ /* This file is part of the program psim. - Copyright (C) 1994-1997, Andrew Cagney + Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -729,7 +729,8 @@ psim_stack(psim *system, "/openprom/init/stack"); if (stack_device != (device*)0) { unsigned_word stack_pointer; - psim_read_register(system, 0, &stack_pointer, "sp", cooked_transfer); + ASSERT (psim_read_register(system, 0, &stack_pointer, "sp", + cooked_transfer) > 0); device_ioctl(stack_device, NULL, /*cpu*/ 0, /*cia*/ @@ -766,7 +767,7 @@ psim_run(psim *system) /* storage manipulation functions */ INLINE_PSIM\ -(void) +(int) psim_read_register(psim *system, int which_cpu, void *buf, @@ -774,7 +775,7 @@ psim_read_register(psim *system, transfer_mode mode) { register_descriptions description; - char cooked_buf[sizeof(unsigned_8)]; + char *cooked_buf; cpu *processor; /* find our processor */ @@ -792,7 +793,8 @@ psim_read_register(psim *system, /* find the register description */ description = register_description(reg); if (description.type == reg_invalid) - error("psim_read_register() invalid register name `%s'\n", reg); + return 0; + cooked_buf = alloca (description.size); /* get the cooked value */ switch (description.type) { @@ -877,12 +879,13 @@ psim_read_register(psim *system, memcpy(buf/*dest*/, cooked_buf/*src*/, description.size); } + return description.size; } INLINE_PSIM\ -(void) +(int) psim_write_register(psim *system, int which_cpu, const void *buf, @@ -891,7 +894,7 @@ psim_write_register(psim *system, { cpu *processor; register_descriptions description; - char cooked_buf[sizeof(unsigned_8)]; + char *cooked_buf; /* find our processor */ if (which_cpu == MAX_NR_PROCESSORS) { @@ -901,21 +904,23 @@ psim_write_register(psim *system, else which_cpu = system->last_cpu; } + + /* find the description of the register */ + description = register_description(reg); + if (description.type == reg_invalid) + return 0; + cooked_buf = alloca (description.size); + if (which_cpu == -1) { int i; for (i = 0; i < system->nr_cpus; i++) psim_write_register(system, i, buf, reg, mode); - return; + return description.size; } ASSERT(which_cpu >= 0 && which_cpu < system->nr_cpus); processor = system->processors[which_cpu]; - /* find the description of the register */ - description = register_description(reg); - if (description.type == reg_invalid) - error("psim_write_register() invalid register name %s\n", reg); - /* If the data is comming in raw (target order), need to cook it into host order before putting it into PSIM's internal structures */ if (mode == raw_transfer) { @@ -981,6 +986,7 @@ psim_write_register(psim *system, } + return description.size; } -- cgit v1.1