Move common headers to common.h, remove util and debugger from being first class include directories

This commit is contained in:
Jeffrey Pfau 2014-04-02 23:50:20 -07:00
parent 73d32e7cc7
commit ecb1939ff1
55 changed files with 98 additions and 107 deletions

View File

@ -16,8 +16,7 @@ source_group("GBA board" FILES ${GBA_SRC} ${RENDERER_SRC})
source_group("Utilities" FILES ${UTIL_SRC})
include_directories(${CMAKE_SOURCE_DIR}/src/arm)
include_directories(${CMAKE_SOURCE_DIR}/src/gba)
include_directories(${CMAKE_SOURCE_DIR}/src/debugger)
include_directories(${CMAKE_SOURCE_DIR}/src/util)
include_directories(${CMAKE_SOURCE_DIR}/src)
if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0600)

View File

@ -4,8 +4,6 @@
#include "isa-inlines.h"
#include "isa-thumb.h"
#include <limits.h>
static inline enum RegisterBank _ARMSelectBank(enum PrivilegeMode);
void ARMSetPrivilegeMode(struct ARMCore* cpu, enum PrivilegeMode mode) {

View File

@ -1,19 +1,7 @@
#ifndef ARM_H
#define ARM_H
#include <stdint.h>
#ifdef __POWERPC__
#define LOAD_32(DEST, ADDR, ARR) asm("lwbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR))
#define LOAD_16(DEST, ADDR, ARR) asm("lhbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR))
#define STORE_32(SRC, ADDR, ARR) asm("stwbrx %0, %1, %2" : : "r"(SRC), "r"(ADDR), "r"(ARR))
#define STORE_16(SRC, ADDR, ARR) asm("sthbrx %0, %1, %2" : : "r"(SRC), "r"(ADDR), "r"(ARR))
#else
#define LOAD_32(DEST, ADDR, ARR) DEST = ((uint32_t*) ARR)[(ADDR) >> 2]
#define LOAD_16(DEST, ADDR, ARR) DEST = ((uint16_t*) ARR)[(ADDR) >> 1]
#define STORE_32(SRC, ADDR, ARR) ((uint32_t*) ARR)[(ADDR) >> 2] = SRC
#define STORE_16(SRC, ADDR, ARR) ((uint16_t*) ARR)[(ADDR) >> 1] = SRC
#endif
#include "common.h"
enum {
ARM_SP = 13,

26
src/arm/common.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef COMMON_H
#define COMMON_H
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __POWERPC__
#define LOAD_32(DEST, ADDR, ARR) asm("lwbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR))
#define LOAD_16(DEST, ADDR, ARR) asm("lhbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR))
#define STORE_32(SRC, ADDR, ARR) asm("stwbrx %0, %1, %2" : : "r"(SRC), "r"(ADDR), "r"(ARR))
#define STORE_16(SRC, ADDR, ARR) asm("sthbrx %0, %1, %2" : : "r"(SRC), "r"(ADDR), "r"(ARR))
#else
#define LOAD_32(DEST, ADDR, ARR) DEST = ((uint32_t*) ARR)[(ADDR) >> 2]
#define LOAD_16(DEST, ADDR, ARR) DEST = ((uint16_t*) ARR)[(ADDR) >> 1]
#define STORE_32(SRC, ADDR, ARR) ((uint32_t*) ARR)[(ADDR) >> 2] = SRC
#define STORE_16(SRC, ADDR, ARR) ((uint16_t*) ARR)[(ADDR) >> 1] = SRC
#endif
#endif

View File

@ -1,7 +1,7 @@
#ifndef ISA_ARM_H
#define ISA_ARM_H
#include <stdint.h>
#include "common.h"
#define ARM_PREFETCH_CYCLES (1 + cpu->memory->activePrefetchCycles32)

View File

@ -1,6 +1,8 @@
#ifndef ISA_INLINES_H
#define ISA_INLINES_H
#include "common.h"
#include "arm.h"
#define UNUSED(V) (void)(V)

View File

@ -1,7 +1,7 @@
#ifndef ISA_THUMB_H
#define ISA_THUMB_H
#include <stdint.h>
#include "common.h"
struct ARMCore;

View File

@ -1,11 +1,6 @@
#include "cli-debugger.h"
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef USE_PTHREADS
#include <pthread.h>

View File

@ -1,6 +1,8 @@
#ifndef CLI_DEBUGGER_H
#define CLI_DEBUGGER_H
#include "common.h"
#include "debugger.h"
#include <histedit.h>

View File

@ -4,8 +4,6 @@
#include "memory-debugger.h"
#include <stdlib.h>
static void _checkBreakpoints(struct ARMDebugger* debugger) {
struct DebugBreakpoint* breakpoint;
int instructionLength;

View File

@ -1,6 +1,8 @@
#ifndef DEBUGGER_H
#define DEBUGGER_H
#include "common.h"
#include "arm.h"
enum DebuggerState {

View File

@ -1,8 +1,6 @@
#include "gdb-stub.h"
#include <errno.h>
#include <signal.h>
#include <string.h>
enum GDBError {
GDB_NO_ERROR = 0x00,

View File

@ -1,8 +1,11 @@
#ifndef GDB_STUB_H
#define GDB_STUB_H
#include "debugger.h"
#include "socket.h"
#include "common.h"
#include "debugger/debugger.h"
#include "util/socket.h"
#define GDB_STUB_MAX_LINE 1200

View File

@ -2,8 +2,6 @@
#include "debugger.h"
#include <string.h>
static void ARMDebuggerShim_store32(struct ARMMemory*, uint32_t address, int32_t value, int* cycleCounter);
static void ARMDebuggerShim_store16(struct ARMMemory*, uint32_t address, int16_t value, int* cycleCounter);
static void ARMDebuggerShim_store8(struct ARMMemory*, uint32_t address, int8_t value, int* cycleCounter);

View File

@ -1,6 +1,8 @@
#ifndef MEMORY_DEBUGGER_H
#define MEMORY_DEBUGGER_H
#include "common.h"
#include "arm.h"
struct ARMDebugger;

View File

@ -5,9 +5,6 @@
#include "gba-serialize.h"
#include "gba-thread.h"
#include <limits.h>
#include <math.h>
const unsigned GBA_AUDIO_SAMPLES = 512;
const unsigned GBA_AUDIO_FIFO_SIZE = 8 * sizeof(int32_t);
#define SWEEP_CYCLES (GBA_ARM7TDMI_FREQUENCY / 128)

View File

@ -1,9 +1,9 @@
#ifndef GBA_AUDIO_H
#define GBA_AUDIO_H
#include "circle-buffer.h"
#include "common.h"
#include <stdint.h>
#include "util/circle-buffer.h"
struct GBADMA;

View File

@ -4,9 +4,6 @@
#include "gba-io.h"
#include "gba-memory.h"
#include <math.h>
#include <stdlib.h>
const uint32_t GBA_BIOS_CHECKSUM = 0xBAAE187F;
const uint32_t GBA_DS_BIOS_CHECKSUM = 0xBAAE1880;

View File

@ -1,9 +1,9 @@
#ifndef GBA_BIOS_H
#define GBA_BIOS_H
#include "arm.h"
#include "common.h"
#include <string.h>
#include "arm.h"
void GBASwi16(struct ARMBoard* board, int immediate);
void GBASwi32(struct ARMBoard* board, int immediate);

View File

@ -1,7 +1,7 @@
#ifndef GBA_GPIO_H
#define GBA_GPIO_H
#include <stdint.h>
#include "common.h"
#define IS_GPIO_REGISTER(reg) ((reg) == GPIO_REG_DATA || (reg) == GPIO_REG_DIRECTION || (reg) == GPIO_REG_CONTROL)

View File

@ -1,6 +1,8 @@
#ifndef GBA_IO_H
#define GBA_IO_H
#include "common.h"
#include "gba.h"
enum GBAIORegisters {

View File

@ -4,11 +4,7 @@
#include "gba-io.h"
#include "gba-serialize.h"
#include "hle-bios.h"
#include "memory.h"
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "util/memory.h"
static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t region);
static int GBAWaitMultiple(struct ARMMemory* memory, uint32_t startAddress, int count);

View File

@ -1,13 +1,13 @@
#ifndef GBA_MEMORY_H
#define GBA_MEMORY_H
#include "common.h"
#include "arm.h"
#include "gba-gpio.h"
#include "gba-savedata.h"
#include <string.h>
enum GBAMemoryRegion {
REGION_BIOS = 0x0,
REGION_WORKING_RAM = 0x2,

View File

@ -1,12 +1,11 @@
#include "gba-savedata.h"
#include "gba.h"
#include "memory.h"
#include "util/memory.h"
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
static void _flashSwitchBank(struct GBASavedata* savedata, int bank);
static void _flashErase(struct GBASavedata* savedata);

View File

@ -1,7 +1,7 @@
#ifndef GBA_SAVEDATA_H
#define GBA_SAVEDATA_H
#include <stdint.h>
#include "common.h"
enum SavedataType {
SAVEDATA_NONE = 0,

View File

@ -1,7 +1,7 @@
#ifndef GBA_SENSORS_H
#define GBA_SENSORS_H
#include <stdint.h>
#include "common.h"
struct GBARotationSource {
void (*sample)(struct GBARotationSource*);

View File

@ -3,13 +3,10 @@
#include "gba-audio.h"
#include "gba-io.h"
#include "gba-thread.h"
#include "memory.h"
#include "util/memory.h"
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
const uint32_t GBA_SAVESTATE_MAGIC = 0x01000000;

View File

@ -1,6 +1,8 @@
#ifndef GBA_SERIALIZE_H
#define GBA_SERIALIZE_H
#include "common.h"
#include "gba.h"
const uint32_t GBA_SAVESTATE_MAGIC;

View File

@ -2,8 +2,6 @@
#include "gba-io.h"
#include <limits.h>
static struct GBASIODriver* _lookupDriver(struct GBASIO* sio, enum GBASIOMode mode) {
switch (mode) {
case SIO_NORMAL_8:

View File

@ -1,7 +1,7 @@
#ifndef GBA_SIO_H
#define GBA_SIO_H
#include <stdint.h>
#include "common.h"
enum GBASIOMode {
SIO_NORMAL_8 = 0,

View File

@ -1,11 +1,11 @@
#include "gba-thread.h"
#include "arm.h"
#include "debugger.h"
#include "gba.h"
#include "gba-serialize.h"
#include <stdlib.h>
#include "debugger/debugger.h"
#include <signal.h>
#ifdef USE_PTHREADS

View File

@ -1,8 +1,11 @@
#ifndef GBA_THREAD_H
#define GBA_THREAD_H
#include "common.h"
#include "gba.h"
#include "threading.h"
#include "util/threading.h"
struct GBAThread;
typedef void (*ThreadCallback)(struct GBAThread* threadContext);

View File

@ -4,10 +4,8 @@
#include "gba-io.h"
#include "gba-serialize.h"
#include "gba-thread.h"
#include "memory.h"
#include <limits.h>
#include <string.h>
#include "util/memory.h"
static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer);
static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer);

View File

@ -1,9 +1,9 @@
#ifndef GBA_VIDEO_H
#define GBA_VIDEO_H
#include "gba-memory.h"
#include "common.h"
#include <stdint.h>
#include "gba-memory.h"
enum {
VIDEO_CYCLES_PER_PIXEL = 4,

View File

@ -4,14 +4,11 @@
#include "gba-io.h"
#include "gba-sio.h"
#include "gba-thread.h"
#include "memory.h"
#include "debugger.h"
#include "util/memory.h"
#include "debugger/debugger.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
const uint32_t GBA_ARM7TDMI_FREQUENCY = 0x1000000;

View File

@ -1,16 +1,16 @@
#ifndef GBA_H
#define GBA_H
#include "common.h"
#include "arm.h"
#include "debugger.h"
#include "debugger/debugger.h"
#include "gba-memory.h"
#include "gba-video.h"
#include "gba-audio.h"
#include "gba-sio.h"
#include <stdarg.h>
extern const uint32_t GBA_ARM7TDMI_FREQUENCY;
enum GBAIRQ {

View File

@ -1,8 +1,7 @@
#ifndef HLE_BIOS_H
#define HLE_BIOS_H
#include <stdint.h>
#include <string.h>
#include "common.h"
extern const size_t hleBiosLength;
extern const uint8_t hleBios[];

View File

@ -1,6 +1,8 @@
#ifndef VIDEO_GLSL_H
#define VIDEO_GLSL_H
#include "common.h"
#include "gba-video.h"
#include <pthread.h>

View File

@ -3,8 +3,6 @@
#include "gba.h"
#include "gba-io.h"
#include <string.h>
#define UNUSED(X) (void) (X)
static const int _objSizes[32] = {

View File

@ -1,9 +1,9 @@
#ifndef VIDEO_SOFTWARE_H
#define VIDEO_SOFTWARE_H
#include "gba-video.h"
#include "common.h"
#include <pthread.h>
#include "gba-video.h"
#ifdef COLOR_16_BIT
typedef uint16_t color_t;

View File

@ -15,7 +15,6 @@
#include <errno.h>
#include <signal.h>
#include <sys/time.h>
#include <unistd.h>
static int _GBASDLInit(void);
static void _GBASDLDeinit(void);

View File

@ -5,9 +5,6 @@
#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static void _GBAPerfRunloop(struct GBAThread* context, int* frames);
static void _GBAPerfShutdown(int signal);

View File

@ -1,4 +1,4 @@
#include "memory.h"
#include "util/memory.h"
#include <sys/mman.h>

View File

@ -1,4 +1,4 @@
#include "debugger.h"
#include "debugger/debugger.h"
#include "gba-thread.h"
#include "gba.h"
#include "renderers/video-software.h"
@ -16,7 +16,6 @@
#include <malloc.h>
#include <signal.h>
#include <sys/time.h>
#include <unistd.h>
struct GBAVideoEGLRenderer {
struct GBAVideoSoftwareRenderer d;

View File

@ -1,4 +1,4 @@
#include "cli-debugger.h"
#include "debugger/cli-debugger.h"
#include "gba-thread.h"
#include "gba.h"
#include "sdl-audio.h"

View File

@ -1,6 +1,8 @@
#ifndef SDL_AUDIO_H
#define SDL_AUDIO_H
#include "common.h"
#include <SDL.h>
struct GBASDLAudio {

View File

@ -1,6 +1,6 @@
#include "sdl-events.h"
#include "debugger.h"
#include "debugger/debugger.h"
#include "gba-io.h"
#include "gba-serialize.h"
#include "gba-video.h"

View File

@ -1,6 +1,8 @@
#ifndef SDL_EVENTS_H
#define SDL_EVENTS_H
#include "common.h"
#include "gba-thread.h"
#include <SDL.h>

View File

@ -1,4 +1,4 @@
#include "debugger.h"
#include "debugger/debugger.h"
#include "gba-thread.h"
#include "gba.h"
#include "renderers/video-software.h"
@ -11,7 +11,6 @@
#include <errno.h>
#include <signal.h>
#include <sys/time.h>
#include <unistd.h>
struct SoftwareRenderer {
struct GBAVideoSoftwareRenderer d;

View File

@ -1,4 +1,4 @@
#include "memory.h"
#include "util/memory.h"
#include <io.h>
#include <Windows.h>

View File

@ -1,8 +1,5 @@
#include "circle-buffer.h"
#include <stddef.h>
#include <stdlib.h>
#ifndef NDEBUG
static int _checkIntegrity(struct CircleBuffer* buffer) {
if ((int8_t*) buffer->writePtr - (int8_t*) buffer->readPtr == buffer->size) {

View File

@ -1,8 +1,7 @@
#ifndef CIRCLE_BUFFER_H
#define CIRCLE_BUFFER_H
#include <stdint.h>
#include <string.h>
#include "common.h"
struct CircleBuffer {
void* data;

View File

@ -1,7 +1,7 @@
#ifndef MEMORY_H
#define MEMORY_H
#include <unistd.h>
#include "common.h"
#define MEMORY_READ 1
#define MEMORY_WRITE 2
@ -10,4 +10,4 @@ void* anonymousMemoryMap(size_t size);
void* fileMemoryMap(int fd, size_t size, int flags);
void mappedMemoryFree(void* memory, size_t size);
#endif
#endif

View File

@ -1,6 +1,8 @@
#ifndef SOCKET_H
#define SOCKET_H
#include "common.h"
#ifdef _WIN32
#include <winsock2.h>
@ -9,9 +11,7 @@ typedef SOCKET Socket;
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <sys/socket.h>
#include <unistd.h>
typedef int Socket;
#endif

View File

@ -1,6 +1,7 @@
#ifndef THREADING_H
#define THREADING_H
#include "common.h"
#ifdef USE_PTHREADS
#include <pthread.h>