diff --git a/Makefile b/Makefile
index d3794b7..99e2dee 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,7 @@ export DBUILTL := $(shell date +'%Y-%m-%d %H:%M:%S')
export OUTDIR := output
export RELDIR := release
+export COMMON_DIR := ../common
# Definitions for initial RAM disk
VRAM_OUT := $(OUTDIR)/vram0.tar
diff --git a/Makefile.build b/Makefile.build
new file mode 100755
index 0000000..27be973
--- /dev/null
+++ b/Makefile.build
@@ -0,0 +1,35 @@
+
+OBJECTS := $(patsubst $(SOURCE)/%.s, $(BUILD)/%.o, \
+ $(patsubst $(SOURCE)/%.c, $(BUILD)/%.o, \
+ $(call rwildcard, $(SOURCE), *.s *.c)))
+
+OBJECTS_COMMON := $(patsubst $(COMMON_DIR)/%.c, $(BUILD)/%.cmn.o, \
+ $(call rwildcard, $(COMMON_DIR), *.c))
+
+.PHONY: all
+all: $(TARGET).elf
+
+.PHONY: clean
+clean:
+ @rm -rf $(BUILD) $(TARGET).elf $(TARGET).map
+
+$(TARGET).elf: $(OBJECTS) $(OBJECTS_COMMON)
+ @mkdir -p "$(@D)"
+ @$(CC) $(LDFLAGS) $^ -o $@
+
+$(BUILD)/%.cmn.o: $(COMMON_DIR)/%.c
+ @mkdir -p "$(@D)"
+ @echo "[$(PROCESSOR)] $<"
+ @$(CC) -c $(CFLAGS) -o $@ $<
+
+$(BUILD)/%.o: $(SOURCE)/%.c
+ @mkdir -p "$(@D)"
+ @echo "[$(PROCESSOR)] $<"
+ @$(CC) -c $(CFLAGS) -o $@ $<
+
+$(BUILD)/%.o: $(SOURCE)/%.s
+ @mkdir -p "$(@D)"
+ @echo "[$(PROCESSOR)] $<"
+ @$(CC) -c $(ASFLAGS) -o $@ $<
+
+include $(call rwildcard, $(BUILD), *.d)
diff --git a/arm11/Makefile b/arm11/Makefile
index c7ed07b..09dde18 100644
--- a/arm11/Makefile
+++ b/arm11/Makefile
@@ -14,30 +14,4 @@ CFLAGS += $(SUBARCH) $(INCLUDE)
LDFLAGS += $(SUBARCH) -Wl,-Map,$(TARGET).map
include ../Makefile.common
-
-OBJECTS = $(patsubst $(SOURCE)/%.s, $(BUILD)/%.o, \
- $(patsubst $(SOURCE)/%.c, $(BUILD)/%.o, \
- $(call rwildcard, $(SOURCE), *.s *.c)))
-
-.PHONY: all
-all: $(TARGET).elf
-
-.PHONY: clean
-clean:
- @rm -rf $(BUILD) $(TARGET).elf $(TARGET).map
-
-$(TARGET).elf: $(OBJECTS)
- @mkdir -p "$(@D)"
- @$(CC) $(LDFLAGS) $^ -o $@
-
-$(BUILD)/%.o: $(SOURCE)/%.c
- @mkdir -p "$(@D)"
- @echo "[$(PROCESSOR)] $<"
- @$(CC) -c $(CFLAGS) -o $@ $<
-
-$(BUILD)/%.o: $(SOURCE)/%.s
- @mkdir -p "$(@D)"
- @echo "[$(PROCESSOR)] $<"
- @$(CC) -c $(ASFLAGS) -o $@ $<
-
-include $(call rwildcard, $(BUILD), *.d)
+include ../Makefile.build
diff --git a/arm9/Makefile b/arm9/Makefile
index 9bed11d..e9487f0 100644
--- a/arm9/Makefile
+++ b/arm9/Makefile
@@ -14,30 +14,4 @@ CFLAGS += $(SUBARCH) $(INCLUDE) -fno-builtin-memcpy -flto
LDFLAGS += $(SUBARCH) -Wl,-Map,$(TARGET).map -flto
include ../Makefile.common
-
-OBJECTS = $(patsubst $(SOURCE)/%.s, $(BUILD)/%.o, \
- $(patsubst $(SOURCE)/%.c, $(BUILD)/%.o, \
- $(call rwildcard, $(SOURCE), *.s *.c)))
-
-.PHONY: all
-all: $(TARGET).elf
-
-.PHONY: clean
-clean:
- @rm -rf $(BUILD) $(TARGET).elf $(TARGET).map
-
-$(TARGET).elf: $(OBJECTS)
- @mkdir -p "$(@D)"
- @$(CC) $(LDFLAGS) $^ -o $@
-
-$(BUILD)/%.o: $(SOURCE)/%.c
- @mkdir -p "$(@D)"
- @echo "[$(PROCESSOR)] $<"
- @$(CC) -c $(CFLAGS) -o $@ $<
-
-$(BUILD)/%.o: $(SOURCE)/%.s
- @mkdir -p "$(@D)"
- @echo "[$(PROCESSOR)] $<"
- @$(CC) -c $(ASFLAGS) -o $@ $<
-
-include $(call rwildcard, $(BUILD), *.d)
+include ../Makefile.build
diff --git a/common/common.h b/common/common.h
index 2edb114..5e81eeb 100755
--- a/common/common.h
+++ b/common/common.h
@@ -61,23 +61,6 @@
#define STATIC_ASSERT(...) \
_Static_assert((__VA_ARGS__), #__VA_ARGS__)
-static inline u32 xbits(u32 *map, u32 start, u32 n)
-{
- u32 ret, mask, off, shift;
-
- if (n > 32)
- return -1;
-
- mask = ((u32)(1 << n)) - 1;
- off = start / 32;
- shift = start % 32;
-
- ret = map[off] >> shift;
- if ((n + shift) > 32)
- ret |= map[off+1] << (32 - shift);
- return ret & mask;
-}
-
// standard output path (support file paths are in support.h)
#define OUTPUT_PATH "0:/gm9/out"
diff --git a/common/pxi.c b/common/pxi.c
new file mode 100755
index 0000000..9f1904d
--- /dev/null
+++ b/common/pxi.c
@@ -0,0 +1,59 @@
+/*
+ * This file is part of GodMode9
+ * Copyright (C) 2019 d0k3, Wolfvak
+ *
+ * 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
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+
+void PXI_Barrier(u8 barrier_id)
+{
+ PXI_SetRemote(barrier_id);
+ PXI_WaitRemote(barrier_id);
+}
+
+void PXI_Reset(void)
+{
+ *PXI_SYNC_IRQ = 0;
+ *PXI_CNT = PXI_CNT_SEND_FIFO_FLUSH | PXI_CNT_ENABLE_FIFO;
+ for (int i = 0; i < PXI_FIFO_LEN; i++)
+ *PXI_RECV;
+
+ *PXI_CNT = 0;
+ *PXI_CNT = PXI_CNT_RECV_FIFO_AVAIL_IRQ | PXI_CNT_ENABLE_FIFO |
+ PXI_CNT_ACKNOWLEDGE_ERROR;
+
+ PXI_SetRemote(0xFF);
+}
+
+void PXI_SendArray(const u32 *w, u32 c)
+{
+ while(c--)
+ PXI_Send(*(w++));
+}
+
+void PXI_RecvArray(u32 *w, u32 c)
+{
+ while(c--)
+ *(w++) = PXI_Recv();
+}
+
+u32 PXI_DoCMD(u32 cmd, const u32 *args, u32 argc)
+{
+ PXI_Send((argc << 16) | cmd);
+ PXI_SendArray(args, argc);
+ return PXI_Recv();
+}
diff --git a/common/pxi.h b/common/pxi.h
index 1bb5ee0..8d8cf84 100644
--- a/common/pxi.h
+++ b/common/pxi.h
@@ -86,26 +86,6 @@ static inline void PXI_WaitRemote(u8 msg)
while(PXI_GetRemote() != msg);
}
-static inline void PXI_Reset(void)
-{
- *PXI_SYNC_IRQ = 0;
- *PXI_CNT = PXI_CNT_SEND_FIFO_FLUSH | PXI_CNT_ENABLE_FIFO;
- for (int i = 0; i < PXI_FIFO_LEN; i++)
- *PXI_RECV;
-
- *PXI_CNT = 0;
- *PXI_CNT = PXI_CNT_RECV_FIFO_AVAIL_IRQ | PXI_CNT_ENABLE_FIFO |
- PXI_CNT_ACKNOWLEDGE_ERROR;
-
- PXI_SetRemote(0xFF);
-}
-
-static inline void PXI_Barrier(u8 barrier_id)
-{
- PXI_SetRemote(barrier_id);
- PXI_WaitRemote(barrier_id);
-}
-
static inline void PXI_Send(u32 w)
{
while(*PXI_CNT & PXI_CNT_SEND_FIFO_FULL);
@@ -118,19 +98,10 @@ static inline u32 PXI_Recv(void)
return *PXI_RECV;
}
-static inline void PXI_SendArray(const u32 *w, u32 c)
-{
- while(c--) PXI_Send(*(w++));
-}
+void PXI_Barrier(u8 barrier_id);
+void PXI_Reset(void);
-static inline void PXI_RecvArray(u32 *w, u32 c)
-{
- while(c--) *(w++) = PXI_Recv();
-}
+void PXI_SendArray(const u32 *w, u32 c);
+void PXI_RecvArray(u32 *w, u32 c);
-static inline u32 PXI_DoCMD(u32 cmd, const u32 *args, u32 argc)
-{
- PXI_Send((argc << 16) | cmd);
- PXI_SendArray(args, argc);
- return PXI_Recv();
-}
+u32 PXI_DoCMD(u32 cmd, const u32 *args, u32 argc);