X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=deps%2Flightrec%2Flightrec.h;h=bd878c86e83db487048bb33e9d03d8c653b9bb58;hb=cb72ea130a5ef1b2f47691ed586ad48bb0c39269;hp=d0793c0a49b7a9a201e7361ca27d2ea0ac64a30f;hpb=a34093eb63d1645fd2de9b412efe2587df9fdb3f;p=pcsx_rearmed.git diff --git a/deps/lightrec/lightrec.h b/deps/lightrec/lightrec.h index d0793c0a..bd878c86 100644 --- a/deps/lightrec/lightrec.h +++ b/deps/lightrec/lightrec.h @@ -1,15 +1,6 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2016-2020 Paul Cercueil - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Copyright (C) 2016-2021 Paul Cercueil */ #ifndef __LIGHTREC_H__ @@ -37,6 +28,21 @@ extern "C" { # define __api #endif +#ifndef __cnst +# ifdef __GNUC__ +# define __cnst __attribute__((const)) +# else +# define __cnst +# endif +#endif +#ifndef __pure +# ifdef __GNUC__ +# define __pure __attribute__((pure)) +# else +# define __pure +# endif +#endif + typedef uint64_t u64; typedef uint32_t u32; typedef uint16_t u16; @@ -52,10 +58,11 @@ struct lightrec_mem_map; /* Exit flags */ #define LIGHTREC_EXIT_NORMAL (0) -#define LIGHTREC_EXIT_SYSCALL (1 << 0) +#define LIGHTREC_EXIT_CHECK_INTERRUPT (1 << 0) #define LIGHTREC_EXIT_BREAK (1 << 1) -#define LIGHTREC_EXIT_CHECK_INTERRUPT (1 << 2) +#define LIGHTREC_EXIT_SYSCALL (1 << 2) #define LIGHTREC_EXIT_SEGFAULT (1 << 3) +#define LIGHTREC_EXIT_NOMEM (1 << 4) enum psx_map { PSX_MAP_KERNEL_USER_RAM, @@ -67,14 +74,9 @@ enum psx_map { PSX_MAP_MIRROR1, PSX_MAP_MIRROR2, PSX_MAP_MIRROR3, -}; + PSX_MAP_CODE_BUFFER, -enum mem_type { - MEM_FOR_CODE, - MEM_FOR_MIPS_CODE, - MEM_FOR_IR, - MEM_FOR_LIGHTREC, - MEM_TYPE_END, + PSX_MAP_UNKNOWN, }; struct lightrec_mem_map_ops { @@ -97,17 +99,19 @@ struct lightrec_mem_map { const struct lightrec_mem_map *mirror_of; }; -struct lightrec_cop_ops { - u32 (*mfc)(struct lightrec_state *state, u32 op, u8 reg); - u32 (*cfc)(struct lightrec_state *state, u32 op, u8 reg); - void (*mtc)(struct lightrec_state *state, u32 op, u8 reg, u32 value); - void (*ctc)(struct lightrec_state *state, u32 op, u8 reg, u32 value); - void (*op)(struct lightrec_state *state, u32 op); +struct lightrec_ops { + void (*cop2_notify)(struct lightrec_state *state, u32 op, u32 data); + void (*cop2_op)(struct lightrec_state *state, u32 op); + void (*enable_ram)(struct lightrec_state *state, _Bool enable); + _Bool (*hw_direct)(u32 kaddr, _Bool is_write, u8 size); + void (*code_inv)(void *addr, u32 len); }; -struct lightrec_ops { - struct lightrec_cop_ops cop0_ops; - struct lightrec_cop_ops cop2_ops; +struct lightrec_registers { + u32 gpr[34]; + u32 cp0[32]; + u32 cp2d[32]; + u32 cp2c[32]; }; __api struct lightrec_state *lightrec_init(char *argv0, @@ -119,8 +123,8 @@ __api void lightrec_destroy(struct lightrec_state *state); __api u32 lightrec_execute(struct lightrec_state *state, u32 pc, u32 target_cycle); -__api u32 lightrec_execute_one(struct lightrec_state *state, u32 pc); -__api u32 lightrec_run_interpreter(struct lightrec_state *state, u32 pc); +__api u32 lightrec_run_interpreter(struct lightrec_state *state, + u32 pc, u32 target_cycle); __api void lightrec_invalidate(struct lightrec_state *state, u32 addr, u32 len); __api void lightrec_invalidate_all(struct lightrec_state *state); @@ -130,19 +134,14 @@ __api void lightrec_set_invalidate_mode(struct lightrec_state *state, __api void lightrec_set_exit_flags(struct lightrec_state *state, u32 flags); __api u32 lightrec_exit_flags(struct lightrec_state *state); -__api void lightrec_dump_registers(struct lightrec_state *state, u32 regs[34]); -__api void lightrec_restore_registers(struct lightrec_state *state, - u32 regs[34]); +__api __cnst struct lightrec_registers * +lightrec_get_registers(struct lightrec_state *state); __api u32 lightrec_current_cycle_count(const struct lightrec_state *state); __api void lightrec_reset_cycle_count(struct lightrec_state *state, u32 cycles); __api void lightrec_set_target_cycle_count(struct lightrec_state *state, u32 cycles); -__api unsigned int lightrec_get_mem_usage(enum mem_type type); -__api unsigned int lightrec_get_total_mem_usage(void); -__api float lightrec_get_average_ipi(void); - #ifdef __cplusplus }; #endif