sonarlinting and formatting in src/cpu

This commit is contained in:
Jasmine Iwanek
2023-08-10 15:43:16 -04:00
parent d4cd4ced54
commit be79ea78c7
52 changed files with 5203 additions and 4835 deletions

View File

@@ -26,6 +26,7 @@
#include "386_common.h"
#include "x86_flags.h"
#include "x86seg.h"
#include <86box/plat_unused.h>
#ifdef USE_DYNAREC
# include "codegen.h"
@@ -34,19 +35,26 @@
# define CPU_BLOCK_END()
#endif
x86seg gdt, ldt, idt, tr;
x86seg gdt;
x86seg ldt;
x86seg idt;
x86seg tr;
uint32_t cr2, cr3, cr4;
uint32_t cr2;
uint32_t cr3;
uint32_t cr4;
uint32_t dr[8];
uint32_t use32;
int stack32;
uint32_t *eal_r, *eal_w;
uint32_t *eal_r;
uint32_t *eal_w;
int nmi_enable = 1;
int alt_access, cpl_override = 0;
int alt_access;
int cpl_override = 0;
#ifdef USE_NEW_DYNAREC
uint16_t cpu_cur_status = 0;
@@ -59,23 +67,33 @@ extern uint8_t *pccache2;
extern int optype;
extern uint32_t pccache;
int in_sys = 0, unmask_a20_in_smm = 0;
uint32_t old_rammask = 0xffffffff;
int in_sys = 0;
int unmask_a20_in_smm = 0;
uint32_t old_rammask = 0xffffffff;
int soft_reset_mask = 0;
int smi_latched = 0;
int smm_in_hlt = 0, smi_block = 0;
int smm_in_hlt = 0;
int smi_block = 0;
int prefetch_prefixes = 0;
int tempc, oldcpl, optype, inttype, oddeven = 0;
int tempc;
int oldcpl;
int optype;
int inttype;
int oddeven = 0;
int timetolive;
uint16_t oldcs;
uint32_t oldds, oldss, olddslimit, oldsslimit,
olddslimitw, oldsslimitw;
uint32_t oldds;
uint32_t oldss;
uint32_t olddslimit;
uint32_t oldsslimit;
uint32_t olddslimitw;
uint32_t oldsslimitw;
uint32_t oxpc;
uint32_t rmdat32;
uint32_t backupregs[16];
@@ -99,8 +117,10 @@ int opcode_length[256] = { 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 1, 3,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 1, 1, 1, 1, /* 0xex */
1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 3, 3 }; /* 0xfx */
uint32_t addr64, addr64_2;
uint32_t addr64a[8], addr64a_2[8];
uint32_t addr64;
uint32_t addr64_2;
uint32_t addr64a[8];
uint32_t addr64a_2[8];
static pc_timer_t *cpu_fast_off_timer = NULL;
static double cpu_fast_off_period = 0.0;
@@ -494,12 +514,10 @@ smm_seg_load(x86seg *s)
static void
smram_save_state_p5(uint32_t *saved_state, int in_hlt)
{
int n = 0;
saved_state[SMRAM_FIELD_P5_SMM_REVISION_ID] = SMM_REVISION_ID;
saved_state[SMRAM_FIELD_P5_SMBASE_OFFSET] = smbase;
for (n = 0; n < 8; n++)
for (uint8_t n = 0; n < 8; n++)
saved_state[SMRAM_FIELD_P5_EAX - n] = cpu_state.regs[n].l;
if (in_hlt)
@@ -588,9 +606,7 @@ smram_save_state_p5(uint32_t *saved_state, int in_hlt)
static void
smram_restore_state_p5(uint32_t *saved_state)
{
int n = 0;
for (n = 0; n < 8; n++)
for (uint8_t n = 0; n < 8; n++)
cpu_state.regs[n].l = saved_state[SMRAM_FIELD_P5_EAX - n];
if (saved_state[SMRAM_FIELD_P5_AUTOHALT_RESTART] & 0xffff)
@@ -701,12 +717,10 @@ smram_restore_state_p5(uint32_t *saved_state)
static void
smram_save_state_p6(uint32_t *saved_state, int in_hlt)
{
int n = 0;
saved_state[SMRAM_FIELD_P6_SMM_REVISION_ID] = SMM_REVISION_ID;
saved_state[SMRAM_FIELD_P6_SMBASE_OFFSET] = smbase;
for (n = 0; n < 8; n++)
for (uint8_t n = 0; n < 8; n++)
saved_state[SMRAM_FIELD_P6_EAX - n] = cpu_state.regs[n].l;
if (in_hlt)
@@ -787,9 +801,7 @@ smram_save_state_p6(uint32_t *saved_state, int in_hlt)
static void
smram_restore_state_p6(uint32_t *saved_state)
{
int n = 0;
for (n = 0; n < 8; n++)
for (uint8_t n = 0; n < 8; n++)
cpu_state.regs[n].l = saved_state[SMRAM_FIELD_P6_EAX - n];
if (saved_state[SMRAM_FIELD_P6_AUTOHALT_RESTART] & 0xffff)
@@ -894,12 +906,10 @@ smram_restore_state_p6(uint32_t *saved_state)
static void
smram_save_state_amd_k(uint32_t *saved_state, int in_hlt)
{
int n = 0;
saved_state[SMRAM_FIELD_AMD_K_SMM_REVISION_ID] = SMM_REVISION_ID;
saved_state[SMRAM_FIELD_AMD_K_SMBASE_OFFSET] = smbase;
for (n = 0; n < 8; n++)
for (uint8_t n = 0; n < 8; n++)
saved_state[SMRAM_FIELD_AMD_K_EAX - n] = cpu_state.regs[n].l;
if (in_hlt)
@@ -979,9 +989,7 @@ smram_save_state_amd_k(uint32_t *saved_state, int in_hlt)
static void
smram_restore_state_amd_k(uint32_t *saved_state)
{
int n = 0;
for (n = 0; n < 8; n++)
for (uint8_t n = 0; n < 8; n++)
cpu_state.regs[n].l = saved_state[SMRAM_FIELD_AMD_K_EAX - n];
if (saved_state[SMRAM_FIELD_AMD_K_AUTOHALT_RESTART] & 0xffff)
@@ -1080,7 +1088,7 @@ smram_restore_state_amd_k(uint32_t *saved_state)
}
static void
smram_save_state_cyrix(uint32_t *saved_state, int in_hlt)
smram_save_state_cyrix(uint32_t *saved_state, UNUSED(int in_hlt))
{
saved_state[0] = dr[7];
saved_state[1] = cpu_state.flags | (cpu_state.eflags << 16);
@@ -1104,7 +1112,7 @@ smram_restore_state_cyrix(uint32_t *saved_state)
void
enter_smm(int in_hlt)
{
uint32_t saved_state[SMM_SAVE_STATE_MAP_SIZE], n;
uint32_t saved_state[SMM_SAVE_STATE_MAP_SIZE];
uint32_t smram_state = smbase + 0x10000;
/* If it's a CPU on which SMM is not supported, do nothing. */
@@ -1231,7 +1239,7 @@ enter_smm(int in_hlt)
writememl(0, smram_state - 0x18, saved_state[5]);
writememl(0, smram_state - 0x24, saved_state[6]);
} else {
for (n = 0; n < SMM_SAVE_STATE_MAP_SIZE; n++) {
for (uint8_t n = 0; n < SMM_SAVE_STATE_MAP_SIZE; n++) {
smram_state -= 4;
writememl(0, smram_state, saved_state[n]);
}
@@ -1291,7 +1299,7 @@ enter_smm_check(int in_hlt)
void
leave_smm(void)
{
uint32_t saved_state[SMM_SAVE_STATE_MAP_SIZE], n;
uint32_t saved_state[SMM_SAVE_STATE_MAP_SIZE];
uint32_t smram_state = smbase + 0x10000;
/* If it's a CPU on which SMM is not supported (or not implemented in 86Box), do nothing. */
@@ -1312,7 +1320,7 @@ leave_smm(void)
cyrix_load_seg_descriptor(smram_state - 0x20, &cpu_state.seg_cs);
saved_state[6] = readmeml(0, smram_state - 0x24);
} else {
for (n = 0; n < SMM_SAVE_STATE_MAP_SIZE; n++) {
for (uint8_t n = 0; n < SMM_SAVE_STATE_MAP_SIZE; n++) {
smram_state -= 4;
saved_state[n] = readmeml(0, smram_state);
x386_common_log("Reading %08X from memory at %08X to array element %i\n", saved_state[n], smram_state, n);
@@ -1483,7 +1491,8 @@ int
x86_int_sw_rm(int num)
{
uint32_t addr;
uint16_t new_pc, new_cs;
uint16_t new_pc;
uint16_t new_cs;
flags_rebuild();
cycles -= timing_int;
@@ -1571,8 +1580,10 @@ checkio(uint32_t port, int mask)
int
divl(uint32_t val)
{
uint64_t num, quo;
uint32_t rem, quo32;
uint64_t num;
uint64_t quo;
uint32_t rem;
uint32_t quo32;
if (val == 0) {
divexcp();
@@ -1598,8 +1609,10 @@ divl(uint32_t val)
int
idivl(int32_t val)
{
int64_t num, quo;
int32_t rem, quo32;
int64_t num;
int64_t quo;
int32_t rem;
int32_t quo32;
if (val == 0) {
divexcp();