mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 05:32:47 +00:00
refactor build system code to allow common code to be built for each target
This commit is contained in:
parent
07b2a2beb6
commit
88751ab96a
1
Makefile
1
Makefile
@ -13,6 +13,7 @@ export DBUILTL := $(shell date +'%Y-%m-%d %H:%M:%S')
|
|||||||
|
|
||||||
export OUTDIR := output
|
export OUTDIR := output
|
||||||
export RELDIR := release
|
export RELDIR := release
|
||||||
|
export COMMON_DIR := ../common
|
||||||
|
|
||||||
# Definitions for initial RAM disk
|
# Definitions for initial RAM disk
|
||||||
VRAM_OUT := $(OUTDIR)/vram0.tar
|
VRAM_OUT := $(OUTDIR)/vram0.tar
|
||||||
|
35
Makefile.build
Executable file
35
Makefile.build
Executable file
@ -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)
|
@ -14,30 +14,4 @@ CFLAGS += $(SUBARCH) $(INCLUDE)
|
|||||||
LDFLAGS += $(SUBARCH) -Wl,-Map,$(TARGET).map
|
LDFLAGS += $(SUBARCH) -Wl,-Map,$(TARGET).map
|
||||||
|
|
||||||
include ../Makefile.common
|
include ../Makefile.common
|
||||||
|
include ../Makefile.build
|
||||||
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)
|
|
||||||
|
@ -14,30 +14,4 @@ CFLAGS += $(SUBARCH) $(INCLUDE) -fno-builtin-memcpy -flto
|
|||||||
LDFLAGS += $(SUBARCH) -Wl,-Map,$(TARGET).map -flto
|
LDFLAGS += $(SUBARCH) -Wl,-Map,$(TARGET).map -flto
|
||||||
|
|
||||||
include ../Makefile.common
|
include ../Makefile.common
|
||||||
|
include ../Makefile.build
|
||||||
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)
|
|
||||||
|
@ -61,23 +61,6 @@
|
|||||||
#define STATIC_ASSERT(...) \
|
#define STATIC_ASSERT(...) \
|
||||||
_Static_assert((__VA_ARGS__), #__VA_ARGS__)
|
_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)
|
// standard output path (support file paths are in support.h)
|
||||||
#define OUTPUT_PATH "0:/gm9/out"
|
#define OUTPUT_PATH "0:/gm9/out"
|
||||||
|
59
common/pxi.c
Executable file
59
common/pxi.c
Executable file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
#include <pxi.h>
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
39
common/pxi.h
39
common/pxi.h
@ -86,26 +86,6 @@ static inline void PXI_WaitRemote(u8 msg)
|
|||||||
while(PXI_GetRemote() != 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)
|
static inline void PXI_Send(u32 w)
|
||||||
{
|
{
|
||||||
while(*PXI_CNT & PXI_CNT_SEND_FIFO_FULL);
|
while(*PXI_CNT & PXI_CNT_SEND_FIFO_FULL);
|
||||||
@ -118,19 +98,10 @@ static inline u32 PXI_Recv(void)
|
|||||||
return *PXI_RECV;
|
return *PXI_RECV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void PXI_SendArray(const u32 *w, u32 c)
|
void PXI_Barrier(u8 barrier_id);
|
||||||
{
|
void PXI_Reset(void);
|
||||||
while(c--) PXI_Send(*(w++));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void PXI_RecvArray(u32 *w, u32 c)
|
void PXI_SendArray(const u32 *w, u32 c);
|
||||||
{
|
void PXI_RecvArray(u32 *w, u32 c);
|
||||||
while(c--) *(w++) = PXI_Recv();
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline u32 PXI_DoCMD(u32 cmd, const u32 *args, u32 argc)
|
u32 PXI_DoCMD(u32 cmd, const u32 *args, u32 argc);
|
||||||
{
|
|
||||||
PXI_Send((argc << 16) | cmd);
|
|
||||||
PXI_SendArray(args, argc);
|
|
||||||
return PXI_Recv();
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user