Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few cleanups #45

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.o
*.a
10 changes: 7 additions & 3 deletions arcgrackle/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ifeq ($(strip $(DEVKITPPC)),)
$(error "Set DEVKITPPC in your environment.")
ifneq ($(strip $(DEVKITPPC)),)
PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
endif

ifeq ($(strip $(PREFIX)),)
$(error "Set DEVKITPPC or PREFIX in your environment.")
endif

PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
Expand Down Expand Up @@ -48,7 +52,7 @@ $(TARGET): $(OBJS)
@echo " LINK $@"
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
@cp $(TARGET) $(TARGET:%.elf=%_unstripped.elf)
@strip $(TARGET)
@$(STRIP) $(TARGET)

ifneq ($(LDSCRIPT),)
$(TARGET): $(LDSCRIPT)
Expand Down
4 changes: 2 additions & 2 deletions arcgrackle/source/arcfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2295,7 +2295,7 @@ static FS_METADATA s_Metadata[FILE_TABLE_SIZE] = { 0 };

DSTATUS disk_initialize(void) { return RES_OK; }

DRESULT disk_readp(ULONG DeviceId, BYTE* buff, DWORD sector, UINT offset, UINT count) {
DRESULT disk_readp(UINT DeviceId, BYTE* buff, DWORD sector, UINT offset, UINT count) {
if (DeviceId >= FILE_TABLE_SIZE) return RES_PARERR;
PFS_METADATA Meta = &s_Metadata[DeviceId];
if (Meta->Type != FS_FAT) return RES_PARERR;
Expand Down Expand Up @@ -2333,7 +2333,7 @@ DRESULT disk_readp(ULONG DeviceId, BYTE* buff, DWORD sector, UINT offset, UINT c
return RES_OK;
}

DRESULT disk_writep(ULONG DeviceId, const BYTE* buff, DWORD sc) {
DRESULT disk_writep(UINT DeviceId, const BYTE* buff, DWORD sc) {
if (DeviceId >= FILE_TABLE_SIZE) return RES_PARERR;
PFS_METADATA Meta = &s_Metadata[DeviceId];
if (Meta->Type != FS_FAT) return RES_PARERR;
Expand Down
3 changes: 2 additions & 1 deletion arcgrackle/source/arctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "arc.h"
#include "arctime.h"
#include "timer.h"
#include "pxi.h"

enum {
RTC_TO_UNIX_DIFF = 2082844800,
Expand Down Expand Up @@ -73,4 +74,4 @@ void ArcTimeInit(void) {
PVENDOR_VECTOR_TABLE Api = ARC_VENDOR_VECTORS();
Api->GetTimeRoutine = ArcGetTime;
Api->GetRelativeTimeRoutine = ArcGetRelativeTime;
}
}
3 changes: 2 additions & 1 deletion arcgrackle/source/ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "ide.h"
#include "hdreg.h"
#include "timer.h"

#define __be32_to_cpu(x) ((PU32BE)(ULONG)&(x))->v

Expand Down Expand Up @@ -1558,4 +1559,4 @@ int macio_ide_init(uint32_t addr, int nb_channels)
}

return 0;
}
}
2 changes: 1 addition & 1 deletion arcgrackle/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "getstr.h"
//#include "ppchook.h"
#include "hwdesc.h"
#include "timer.h"

#include "pxi.h"
#include "usbheap.h"
Expand Down Expand Up @@ -808,5 +809,4 @@ void ARC_NORETURN FwMain(PHW_DESCRIPTION Desc) {
ArcMain();
// should never reach here
while (1) {}
return 0;
}
2 changes: 2 additions & 0 deletions arcgrackle/source/usbhub.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include "usb.h"

void fatal(const char* ptr);

// assume that host_to_device is overwritten if necessary
#define DR_PORT gen_bmRequestType(host_to_device, class_type, other_recp)
#define PORT_RESET 0x4
Expand Down
2 changes: 2 additions & 0 deletions arcgrackle/source/usbmsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include "pxi.h"

void fatal(const char* ptr);

#define htonl(x) __builtin_bswap32(x)
#define ntohl(x) __builtin_bswap32(x)
#define htonw(x) __builtin_bswap16(x)
Expand Down
12 changes: 6 additions & 6 deletions arcgrackle/source/usbohci.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ static u32 _phys_to_virt(u32 phys) {
// return uncached address if possible
if (phys >= 0xf0000000) return phys;
if (phys < 0x10000000) return 0x90000000 + phys;
if (phys < 0x80000000) return NULL;
if (phys >= 0x90000000) return NULL;
if (phys < 0x80000000) return 0;
if (phys >= 0x90000000) return 0;
return phys + (0xC0000000 - 0x80000000);
}

static PVOID phys_to_virt(u32 phys) { return (PVOID)_phys_to_virt(phys); }

static u32 virt_to_phys(PVOID _virt) {
u32 virt = (u32)_virt;
if (virt < 0x80000000) return NULL;
if (virt < 0x80000000) return 0;
if (virt < 0x90000000) return (virt - 0x80000000);
if (virt < 0xA0000000) return (virt - 0x90000000);
if (virt < 0xC0000000) return NULL;
if (virt < 0xC0000000) return 0;
if (virt < 0xD0000000) return (virt - 0xC0000000 + 0x80000000);
if (virt < 0xF0000000) return NULL;
if (virt < 0xF0000000) return 0;
return virt;
}

Expand Down Expand Up @@ -238,7 +238,7 @@ ohci_init (void *bar)
init_device_entry (controller, 0);
OHCI_INST (controller)->roothub = controller->devices[0];

controller->reg_base = (u32)virt_to_phys((u32)bar);
controller->reg_base = (u32)virt_to_phys(bar);
OHCI_INST(controller)->opreg = (opreg_t*)bar;
usb_debug("OHCI Version %x.%x\n",
(READ_OPREG(OHCI_INST(controller), HcRevision) >> 4) & 0xf,
Expand Down
10 changes: 6 additions & 4 deletions arcloader_grackle/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
ifeq ($(strip $(DEVKITPPC)),)
$(error "Set DEVKITPPC in your environment.")
ifneq ($(strip $(DEVKITPPC)),)
PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
endif

PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
ifeq ($(strip $(PREFIX)),)
$(error "Set DEVKITPPC or PREFIX in your environment.")
endif

CFLAGS = -mcpu=750 -m32 -mhard-float -mno-eabi -mno-sdata
CFLAGS += -ffreestanding -ffunction-sections -fdata-sections
Expand Down Expand Up @@ -50,7 +52,7 @@ $(TARGET): $(OBJS)
@echo " LINK $@"
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
@cp $(TARGET) $(TARGET:%.elf=%_unstripped.elf)
@strip $(TARGET)
@$(STRIP) $(TARGET)

ifneq ($(LDSCRIPT),)
$(TARGET): $(LDSCRIPT)
Expand Down
2 changes: 1 addition & 1 deletion arcloader_grackle/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ static bool FbSetDepthNv(OFHANDLE Screen) {
NV_PRMCIO_CRTC[1] = 0x03;
__asm__ volatile ("eieio");
// Set PRAMDAC_GENERAL_CONTROL
volatile U32LE* NV_PRAMDAC_GENERAL_CONTROL = (volatile ULONG*)(PCRTC + 0x80600);
volatile U32LE* NV_PRAMDAC_GENERAL_CONTROL = (volatile U32LE*)(PCRTC + 0x80600);
NV_PRAMDAC_GENERAL_CONTROL->v = 0x101130; // PIXMIX_ON | VGA_STATE_SEL | ALT_MODE_SEL | BPC_8BITS
__asm__ volatile ("eieio");
// NV_CIO_CR_OFFSET = stride / 8
Expand Down
10 changes: 6 additions & 4 deletions arcloader_unin/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
ifeq ($(strip $(DEVKITPPC)),)
$(error "Set DEVKITPPC in your environment.")
ifneq ($(strip $(DEVKITPPC)),)
PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
endif

PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
ifeq ($(strip $(PREFIX)),)
$(error "Set DEVKITPPC or PREFIX in your environment.")
endif

CFLAGS = -mcpu=750 -m32 -mhard-float -mno-eabi -mno-sdata
CFLAGS += -ffreestanding -ffunction-sections -fdata-sections
Expand Down Expand Up @@ -50,7 +52,7 @@ $(TARGET): $(OBJS)
@echo " LINK $@"
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
@cp $(TARGET) $(TARGET:%.elf=%_unstripped.elf)
@strip $(TARGET)
@$(STRIP) $(TARGET)

ifneq ($(LDSCRIPT),)
$(TARGET): $(LDSCRIPT)
Expand Down
2 changes: 1 addition & 1 deletion arcloader_unin/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ static bool FbSetDepthNv(OFHANDLE Screen) {
NV_PRMCIO_CRTC[1] = 0x03 | PixelDepth7;
__asm__ volatile ("eieio");
// Set PRAMDAC_GENERAL_CONTROL
volatile U32LE* NV_PRAMDAC_GENERAL_CONTROL = (volatile ULONG*)(PCRTC + 0x80600);
volatile U32LE* NV_PRAMDAC_GENERAL_CONTROL = (volatile U32LE*)(PCRTC + 0x80600);
NV_PRAMDAC_GENERAL_CONTROL->v = 0x101130; // PIXMIX_ON | VGA_STATE_SEL | ALT_MODE_SEL | BPC_8BITS
__asm__ volatile ("eieio");
// NV_CIO_CR_OFFSET = stride / 8
Expand Down
10 changes: 6 additions & 4 deletions arcunin/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
ifeq ($(strip $(DEVKITPPC)),)
$(error "Set DEVKITPPC in your environment.")
ifneq ($(strip $(DEVKITPPC)),)
PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
endif

PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
ifeq ($(strip $(PREFIX)),)
$(error "Set DEVKITPPC or PREFIX in your environment.")
endif

CFLAGS = -mcpu=750 -m32 -mlittle -mhard-float -mno-eabi -mno-sdata
CFLAGS += -ffreestanding -ffunction-sections -fdata-sections
Expand Down Expand Up @@ -48,7 +50,7 @@ $(TARGET): $(OBJS)
@echo " LINK $@"
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
@cp $(TARGET) $(TARGET:%.elf=%_unstripped.elf)
@strip $(TARGET)
@$(STRIP) $(TARGET)

ifneq ($(LDSCRIPT),)
$(TARGET): $(LDSCRIPT)
Expand Down
11 changes: 7 additions & 4 deletions arcunin/baselibc/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
ifneq ($(strip $(DEVKITPPC)),)
PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
endif

ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
ifeq ($(strip $(PREFIX)),)
$(error "Set DEVKITPPC or PREFIX in your environment.")
endif

# You can override the CFLAGS and C compiler externally,
Expand All @@ -21,8 +24,8 @@ ifeq ($(PLATFORM),mipsel)
CFLAGS += -G0 -mno-gpopt -march=r4000 -Os -mel -mgp32 -mfp32 -mabi=32
endif
ifeq ($(PLATFORM),ppc)
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc
AR = $(DEVKITPPC)/bin/powerpc-eabi-gcc-ar
CC = $(PREFIX)gcc
AR = $(PREFIX)ar
CFLAGS += -mcpu=750 -m32 -mhard-float -mno-eabi -mno-sdata -mlittle
endif

Expand Down
4 changes: 2 additions & 2 deletions arcunin/source/arcfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ static FS_METADATA s_Metadata[FILE_TABLE_SIZE] = { 0 };

DSTATUS disk_initialize(void) { return RES_OK; }

DRESULT disk_readp(ULONG DeviceId, BYTE* buff, DWORD sector, UINT offset, UINT count) {
DRESULT disk_readp(UINT DeviceId, BYTE* buff, DWORD sector, UINT offset, UINT count) {
if (DeviceId >= FILE_TABLE_SIZE) return RES_PARERR;
PFS_METADATA Meta = &s_Metadata[DeviceId];
if (Meta->Type != FS_FAT) return RES_PARERR;
Expand Down Expand Up @@ -1962,7 +1962,7 @@ DRESULT disk_readp(ULONG DeviceId, BYTE* buff, DWORD sector, UINT offset, UINT c
return RES_OK;
}

DRESULT disk_writep(ULONG DeviceId, const BYTE* buff, DWORD sc) {
DRESULT disk_writep(UINT DeviceId, const BYTE* buff, DWORD sc) {
if (DeviceId >= FILE_TABLE_SIZE) return RES_PARERR;
PFS_METADATA Meta = &s_Metadata[DeviceId];
if (Meta->Type != FS_FAT) return RES_PARERR;
Expand Down
1 change: 1 addition & 0 deletions arcunin/source/arctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "arc.h"
#include "arctime.h"
#include "timer.h"
#include "pxi.h"

enum {
RTC_TO_UNIX_DIFF = 2082844800,
Expand Down
1 change: 1 addition & 0 deletions arcunin/source/ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "ide.h"
#include "hdreg.h"
#include "timer.h"

#define __be32_to_cpu(x) ((PU32BE)(ULONG)&(x))->v

Expand Down
2 changes: 1 addition & 1 deletion arcunin/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "getstr.h"
//#include "ppchook.h"
#include "hwdesc.h"
#include "timer.h"

#include "pxi.h"
#include "usbheap.h"
Expand Down Expand Up @@ -832,5 +833,4 @@ void ARC_NORETURN FwMain(PHW_DESCRIPTION Desc) {
ArcMain();
// should never reach here
while (1) {}
return 0;
}
2 changes: 2 additions & 0 deletions arcunin/source/usbhub.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include "usb.h"

void fatal(const char* ptr);

// assume that host_to_device is overwritten if necessary
#define DR_PORT gen_bmRequestType(host_to_device, class_type, other_recp)
#define PORT_RESET 0x4
Expand Down
2 changes: 2 additions & 0 deletions arcunin/source/usbmsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include "pxi.h"

void fatal(const char* ptr);

#define htonl(x) __builtin_bswap32(x)
#define ntohl(x) __builtin_bswap32(x)
#define htonw(x) __builtin_bswap16(x)
Expand Down
6 changes: 3 additions & 3 deletions arcunin/source/usbohci.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void endian_swap64(void* buf, ULONG len) {
static u32 _phys_to_virt(u32 phys) {
// return uncached address if possible
if (phys < 0x10000000) return 0x70000000 + phys;
if (phys < 0x80000000) return NULL;
if (phys < 0x80000000) return 0;
if (phys >= 0x90000000) return phys;
return phys - (0x80000000 - 0x60000000);
}
Expand All @@ -67,7 +67,7 @@ static PVOID phys_to_virt(u32 phys) { return (PVOID)_phys_to_virt(phys); }

static u32 virt_to_phys(PVOID _virt) {
u32 virt = (u32)_virt;
if (virt < 0x60000000) return NULL;
if (virt < 0x60000000) return 0;
if (virt < 0x70000000) return (virt - 0x60000000 + 0x80000000);
if (virt < 0x80000000) return (virt - 0x70000000);
if (virt < 0x90000000) return (virt - 0x80000000);
Expand Down Expand Up @@ -245,7 +245,7 @@ ohci_init (void *bar)
init_device_entry (controller, 0);
OHCI_INST (controller)->roothub = controller->devices[0];

controller->reg_base = (u32)virt_to_phys((u32)bar);
controller->reg_base = (u32)virt_to_phys(bar);
OHCI_INST(controller)->opreg = (opreg_t*)bar;
usb_debug("OHCI Version %x.%x\n",
(READ_OPREG(OHCI_INST(controller), HcRevision) >> 4) & 0xf,
Expand Down
11 changes: 7 additions & 4 deletions baselibc/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
ifneq ($(strip $(DEVKITPPC)),)
PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
endif

ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
ifeq ($(strip $(PREFIX)),)
$(error "Set DEVKITPPC or PREFIX in your environment.")
endif

# You can override the CFLAGS and C compiler externally,
Expand All @@ -21,8 +24,8 @@ ifeq ($(PLATFORM),mipsel)
CFLAGS += -G0 -mno-gpopt -march=r4000 -Os -mel -mgp32 -mfp32 -mabi=32
endif
ifeq ($(PLATFORM),ppc)
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc
AR = $(DEVKITPPC)/bin/powerpc-eabi-gcc-ar
CC = $(PREFIX)gcc
AR = $(PREFIX)ar
CFLAGS += -mcpu=750 -m32 -mhard-float -mno-eabi -mno-sdata -mbig
endif

Expand Down