diff --git a/source/alignedseqmemcpy.h b/arm9/source/alignedseqmemcpy.h similarity index 100% rename from source/alignedseqmemcpy.h rename to arm9/source/alignedseqmemcpy.h diff --git a/source/alignedseqmemcpy.s b/arm9/source/alignedseqmemcpy.s similarity index 100% rename from source/alignedseqmemcpy.s rename to arm9/source/alignedseqmemcpy.s diff --git a/arm9/source/arm9_exception_handlers.c b/arm9/source/arm9_exception_handlers.c index ee7bc9f..2cce582 100644 --- a/arm9/source/arm9_exception_handlers.c +++ b/arm9/source/arm9_exception_handlers.c @@ -74,18 +74,10 @@ void __attribute__((noreturn)) arm9ExceptionHandlerMain(u32 *registerDump, u32 t //Copy header (actually optimized by the compiler) *(ExceptionDumpHeader *)FINAL_BUFFER = dumpHeader; -<<<<<<< HEAD:exceptions/arm9/source/mainHandler.c if(ARESCREENSINITIALIZED) I2C_writeReg(I2C_DEV_MCU, 0x22, 1 << 0); //Shutdown LCD ((void (*)())0xFFFF0830)(); //Ensure that all memory transfers have completed and that the data cache has been flushed I2C_writeReg(I2C_DEV_MCU, 0x20, 1 << 2); //Reboot -======= - if(ARESCREENSINITIALIZED) i2cWriteRegisterNoWait(I2C_DEV_MCU, 0x22, 1 << 0); //Shutdown LCD - - ((void (*)())0xFFFF0830)(); //Ensure that all memory transfers have completed and that the data cache has been flushed - - i2cWriteRegisterNoWait(I2C_DEV_MCU, 0x20, 1 << 2); //Reboot ->>>>>>> Do the same for arm9 exceptions:source/arm9_exception_handlers.c while(true); } diff --git a/arm9/source/arm9_exception_handlers.h b/arm9/source/arm9_exception_handlers.h index e48a501..8c21f6f 100644 --- a/arm9/source/arm9_exception_handlers.h +++ b/arm9/source/arm9_exception_handlers.h @@ -29,20 +29,4 @@ extern const u32 arm9ExceptionHandlerAddressTable[6]; extern u32 arm9ExceptionHandlerSvcBreakAddress; -<<<<<<< HEAD:exceptions/arm9/source/types.h -//Common data types -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; -typedef volatile u8 vu8; -typedef volatile u16 vu16; -typedef volatile u32 vu32; -typedef volatile u64 vu64; - -#define PDN_GPU_CNT (*(vu32 *)0x10141200) - -#define ARESCREENSINITIALIZED ((PDN_GPU_CNT & 0xFF) != 1) -======= u32 safecpy(void *dst, const void *src, u32 len); ->>>>>>> Do the same for arm9 exceptions:source/arm9_exception_handlers.h diff --git a/arm9/source/i2c.c b/arm9/source/i2c.c index 573c616..5074cf6 100644 --- a/arm9/source/i2c.c +++ b/arm9/source/i2c.c @@ -180,11 +180,7 @@ bool I2C_readRegBuf(I2cDevice devId, u8 regAddr, u8 *out, u32 size) return true; } -<<<<<<< HEAD bool I2C_writeRegBuf(I2cDevice devId, u8 regAddr, const u8 *in, u32 size) -======= -bool i2cWriteRegisterNoWait(u8 dev_id, u8 reg, u8 data) ->>>>>>> Do the same for arm9 exceptions { const u8 busId = i2cDevTable[devId].busId; I2cRegs *const regs = i2cGetBusRegsBase(busId); @@ -204,7 +200,6 @@ bool i2cWriteRegisterNoWait(u8 dev_id, u8 reg, u8 data) } } -<<<<<<< HEAD regs->REG_I2C_DATA = *in; regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_DIRE_WRITE | I2C_STOP; i2cWaitBusy(regs); @@ -223,15 +218,6 @@ u8 I2C_readReg(I2cDevice devId, u8 regAddr) if(!I2C_readRegBuf(devId, regAddr, &data, 1)) return 0xFF; return data; } -======= - return ret; -} - -bool i2cWriteRegister(u8 dev_id, u8 reg, u8 data) -{ - bool ret = i2cWriteRegisterNoWait(dev_id, reg, data); - wait(3ULL); ->>>>>>> Do the same for arm9 exceptions bool I2C_writeReg(I2cDevice devId, u8 regAddr, u8 data) { diff --git a/arm9/source/i2c.h b/arm9/source/i2c.h index 0f58c5e..ea94422 100644 --- a/arm9/source/i2c.h +++ b/arm9/source/i2c.h @@ -90,7 +90,6 @@ bool I2C_writeRegBuf(I2cDevice devId, u8 regAddr, const u8 *in, u32 size); */ u8 I2C_readReg(I2cDevice devId, u8 regAddr); -<<<<<<< HEAD /** * @brief Writes a byte to a I2C register. * @@ -101,8 +100,3 @@ u8 I2C_readReg(I2cDevice devId, u8 regAddr); * @return Returns true on success and false on failure. */ bool I2C_writeReg(I2cDevice devId, u8 regAddr, u8 data); -======= -u8 i2cReadRegister(u8 dev_id, u8 reg); -bool i2cWriteRegister(u8 dev_id, u8 reg, u8 data); -bool i2cWriteRegisterNoWait(u8 dev_id, u8 reg, u8 data); ->>>>>>> Do the same for arm9 exceptions diff --git a/chainloader/source/cache.s b/chainloader/source/cache.s deleted file mode 100644 index 2184833..0000000 --- a/chainloader/source/cache.s +++ /dev/null @@ -1,60 +0,0 @@ -@ This file is part of Luma3DS -@ Copyright (C) 2016-2019 Aurora Wright, TuxSH -@ -@ 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 3 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 . -@ -@ Additional Terms 7.b and 7.c of GPLv3 apply to this file: -@ * Requiring preservation of specified reasonable legal notices or -@ author attributions in that material or in the Appropriate Legal -@ Notices displayed by works containing it. -@ * Prohibiting misrepresentation of the origin of that material, -@ or requiring that modified versions of such material be marked in -@ reasonable ways as different from the original version. - -.text -.arm -.align 4 - -.global flushCaches -.type flushCaches, %function -flushCaches: - @ Clean and flush both the data cache and instruction caches - - @ Adpated from http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0155a/ch03s03s05.html , - @ and https://github.com/gemarcano/libctr9_io/blob/master/src/ctr_system_ARM.c#L39 as well - @ Note: ARM's example is actually for a 8KB DCache (which is what the 3DS has) - - @ Implemented in bootROM at addresses 0xffff0830 (DCache) and 0xffff0ab4 (ICache) - - mov r1, #0 @ segment counter - outer_loop: - mov r0, #0 @ line counter - - inner_loop: - orr r2, r1, r0 @ generate segment and line address - mcr p15, 0, r2, c7, c14, 2 @ clean and flush the line - add r0, #0x20 @ increment to next line - cmp r0, #0x400 - bne inner_loop - - add r1, #0x40000000 - cmp r1, #0 - bne outer_loop - - mcr p15, 0, r1, c7, c10, 4 @ drain write buffer - - @ Flush instruction cache - mcr p15, 0, r1, c7, c5, 0 - - bx lr diff --git a/chainloader/source/firm.c b/chainloader/source/firm.c deleted file mode 100644 index 00fb51a..0000000 --- a/chainloader/source/firm.c +++ /dev/null @@ -1,42 +0,0 @@ -/* -* This file is part of Luma3DS -* Copyright (C) 2016-2019 Aurora Wright, TuxSH -* -* 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 3 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 . -* -* Additional Terms 7.b and 7.c of GPLv3 apply to this file: -* * Requiring preservation of specified reasonable legal notices or -* author attributions in that material or in the Appropriate Legal -* Notices displayed by works containing it. -* * Prohibiting misrepresentation of the origin of that material, -* or requiring that modified versions of such material be marked in -* reasonable ways as different from the original version. -*/ - -#include "firm.h" -#include "memory.h" -#include "cache.h" - -void disableMpuAndJumpToEntrypoints(int argc, char **argv, void *arm11Entry, void *arm9Entry); - -void launchFirm(Firm *firm, int argc, char **argv) -{ - //Copy FIRM sections to respective memory locations - for(u32 sectionNum = 0; sectionNum < 4; sectionNum++) - memcpy(firm->section[sectionNum].address, (u8 *)firm + firm->section[sectionNum].offset, firm->section[sectionNum].size); - - disableMpuAndJumpToEntrypoints(argc, argv, firm->arm9Entry, firm->arm11Entry); - - __builtin_unreachable(); -} diff --git a/chainloader/source/firm.h b/chainloader/source/firm.h deleted file mode 100644 index 31cdb5b..0000000 --- a/chainloader/source/firm.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* This file is part of Luma3DS -* Copyright (C) 2016-2019 Aurora Wright, TuxSH -* -* 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 3 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 . -* -* Additional Terms 7.b and 7.c of GPLv3 apply to this file: -* * Requiring preservation of specified reasonable legal notices or -* author attributions in that material or in the Appropriate Legal -* Notices displayed by works containing it. -* * Prohibiting misrepresentation of the origin of that material, -* or requiring that modified versions of such material be marked in -* reasonable ways as different from the original version. -*/ - -#pragma once - -#include "types.h" - -typedef struct __attribute__((packed)) -{ - u32 offset; - u8 *address; - u32 size; - u32 procType; - u8 hash[0x20]; -} FirmSection; - -typedef struct __attribute__((packed)) -{ - char magic[4]; - u32 reserved1; - u8 *arm11Entry; - u8 *arm9Entry; - u8 reserved2[0x30]; - FirmSection section[4]; -} Firm; - -void launchFirm(Firm *firm, int argc, char **argv); diff --git a/chainloader/source/memory.c b/chainloader/source/memory.c deleted file mode 100644 index 34eac4d..0000000 --- a/chainloader/source/memory.c +++ /dev/null @@ -1,40 +0,0 @@ -/* -* This file is part of Luma3DS -* Copyright (C) 2016-2019 Aurora Wright, TuxSH -* -* 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 3 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 . -* -* Additional Terms 7.b and 7.c of GPLv3 apply to this file: -* * Requiring preservation of specified reasonable legal notices or -* author attributions in that material or in the Appropriate Legal -* Notices displayed by works containing it. -* * Prohibiting misrepresentation of the origin of that material, -* or requiring that modified versions of such material be marked in -* reasonable ways as different from the original version. -*/ - -/* -* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c -*/ - -#include "memory.h" - -void memcpy(void *dest, const void *src, u32 size) -{ - u8 *destc = (u8 *)dest; - const u8 *srcc = (const u8 *)src; - - for(u32 i = 0; i < size; i++) - destc[i] = srcc[i]; -} diff --git a/chainloader/source/memory.h b/chainloader/source/memory.h deleted file mode 100644 index dae5f6d..0000000 --- a/chainloader/source/memory.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -* This file is part of Luma3DS -* Copyright (C) 2016-2019 Aurora Wright, TuxSH -* -* 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 3 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 . -* -* Additional Terms 7.b and 7.c of GPLv3 apply to this file: -* * Requiring preservation of specified reasonable legal notices or -* author attributions in that material or in the Appropriate Legal -* Notices displayed by works containing it. -* * Prohibiting misrepresentation of the origin of that material, -* or requiring that modified versions of such material be marked in -* reasonable ways as different from the original version. -*/ - -/* -* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c -*/ - -#pragma once - -#include "types.h" - -void memcpy(void *dest, const void *src, u32 size); diff --git a/chainloader/source/start.s b/chainloader/source/start.s deleted file mode 100644 index 68afcae..0000000 --- a/chainloader/source/start.s +++ /dev/null @@ -1,60 +0,0 @@ -@ This file is part of Luma3DS -@ Copyright (C) 2016-2019 Aurora Wright, TuxSH -@ -@ 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 3 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 . -@ -@ Additional Terms 7.b and 7.c of GPLv3 apply to this file: -@ * Requiring preservation of specified reasonable legal notices or -@ author attributions in that material or in the Appropriate Legal -@ Notices displayed by works containing it. -@ * Prohibiting misrepresentation of the origin of that material, -@ or requiring that modified versions of such material be marked in -@ reasonable ways as different from the original version. -.arm - -.section .text.start -.align 4 -.global _start -_start: - ldr sp, =__stack_top__ - b main - -.text -.balign 4 -.global disableMpuAndJumpToEntrypoints -.type disableMpuAndJumpToEntrypoints, %function -disableMpuAndJumpToEntrypoints: - mov r4, r0 - mov r5, r1 - mov r6, r2 - mov r7, r3 - - bl flushCaches - - @ Disable caches / MPU - mrc p15, 0, r0, c1, c0, 0 @ read control register - bic r0, #(1<<12) @ - instruction cache disable - bic r0, #(1<<2) @ - data cache disable - bic r0, #(1<<0) @ - MPU disable - mcr p15, 0, r0, c1, c0, 0 @ write control register - - @ Set the ARM11 entrypoint - mov r0, #0x20000000 - str r7, [r0, #-4] - - @ Jump to the ARM9 entrypoint - mov r0, r4 - mov r1, r5 - ldr r2, =0x3BEEF - bx r6 diff --git a/chainloader/source/types.h b/chainloader/source/types.h deleted file mode 100644 index 7f9c5fe..0000000 --- a/chainloader/source/types.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* This file is part of Luma3DS -* Copyright (C) 2016-2019 Aurora Wright, TuxSH -* -* 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 3 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 . -* -* Additional Terms 7.b and 7.c of GPLv3 apply to this file: -* * Requiring preservation of specified reasonable legal notices or -* author attributions in that material or in the Appropriate Legal -* Notices displayed by works containing it. -* * Prohibiting misrepresentation of the origin of that material, -* or requiring that modified versions of such material be marked in -* reasonable ways as different from the original version. -*/ - -#pragma once - -#include - -//Common data types -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; -typedef volatile u8 vu8; -typedef volatile u16 vu16; -typedef volatile u32 vu32; -typedef volatile u64 vu64; - -struct fb { - u8 *top_left; - u8 *top_right; - u8 *bottom; -}; diff --git a/exceptions/arm9/source/handlers.h b/exceptions/arm9/source/handlers.h deleted file mode 100644 index b4b0d6b..0000000 --- a/exceptions/arm9/source/handlers.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* This file is part of Luma3DS -* Copyright (C) 2016-2019 Aurora Wright, TuxSH -* -* 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 3 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 . -* -* Additional Terms 7.b and 7.c of GPLv3 apply to this file: -* * Requiring preservation of specified reasonable legal notices or -* author attributions in that material or in the Appropriate Legal -* Notices displayed by works containing it. -* * Prohibiting misrepresentation of the origin of that material, -* or requiring that modified versions of such material be marked in -* reasonable ways as different from the original version. -*/ - -#pragma once - -#include "types.h" - -typedef struct __attribute__((packed)) -{ - u32 magic[2]; - u16 versionMinor, versionMajor; - - u16 processor, core; - u32 type; - - u32 totalSize; - u32 registerDumpSize; - u32 codeDumpSize; - u32 stackDumpSize; - u32 additionalDataSize; -} ExceptionDumpHeader; - -void FIQHandler(void); -void undefinedInstructionHandler(void); -void dataAbortHandler(void); -void prefetchAbortHandler(void); - -u32 safecpy(void *dst, const void *src, u32 len); diff --git a/exceptions/arm9/source/i2c.c b/exceptions/arm9/source/i2c.c deleted file mode 100644 index 5074cf6..0000000 --- a/exceptions/arm9/source/i2c.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * This file is part of fastboot 3DS - * Copyright (C) 2017 derrek, profi200 - * - * 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 3 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 "types.h" -#include "i2c.h" - - -#define I2C1_REGS_BASE (0x10161000) - -#define I2C2_REGS_BASE (0x10144000) - -#define I2C3_REGS_BASE (0x10148000) - - -typedef struct -{ - vu8 REG_I2C_DATA; - vu8 REG_I2C_CNT; - vu16 REG_I2C_CNTEX; - vu16 REG_I2C_SCL; -} I2cRegs; - -static const struct -{ - u8 busId; - u8 devAddr; -} i2cDevTable[] = -{ - {0, 0x4A}, - {0, 0x7A}, - {0, 0x78}, - {1, 0x4A}, - {1, 0x78}, - {1, 0x2C}, - {1, 0x2E}, - {1, 0x40}, - {1, 0x44}, - {2, 0xA6}, // TODO: Find out if 0xA6 or 0xD6 is correct - {2, 0xD0}, - {2, 0xD2}, - {2, 0xA4}, - {2, 0x9A}, - {2, 0xA0}, - {1, 0xEE}, - {0, 0x40}, - {2, 0x54} -}; - - - -static void i2cWaitBusy(I2cRegs *const regs) -{ - while(regs->REG_I2C_CNT & I2C_ENABLE); -} - -static I2cRegs* i2cGetBusRegsBase(u8 busId) -{ - I2cRegs *base; - switch(busId) - { - case 0: - base = (I2cRegs*)I2C1_REGS_BASE; - break; - case 1: - base = (I2cRegs*)I2C2_REGS_BASE; - break; - case 2: - base = (I2cRegs*)I2C3_REGS_BASE; - break; - default: - base = NULL; - } - - return base; -} - -void I2C_init(void) -{ - I2cRegs *regs = i2cGetBusRegsBase(0); // Bus 1 - i2cWaitBusy(regs); - regs->REG_I2C_CNTEX = 2; // ? - regs->REG_I2C_SCL = 1280; // ? - - regs = i2cGetBusRegsBase(1); // Bus 2 - i2cWaitBusy(regs); - regs->REG_I2C_CNTEX = 2; // ? - regs->REG_I2C_SCL = 1280; // ? - - regs = i2cGetBusRegsBase(2); // Bus 3 - i2cWaitBusy(regs); - regs->REG_I2C_CNTEX = 2; // ? - regs->REG_I2C_SCL = 1280; // ? -} - -static bool i2cStartTransfer(I2cDevice devId, u8 regAddr, bool read, I2cRegs *const regs) -{ - const u8 devAddr = i2cDevTable[devId].devAddr; - - - u32 i = 0; - for(; i < 8; i++) - { - i2cWaitBusy(regs); - - // Select device and start. - regs->REG_I2C_DATA = devAddr; - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_START; - i2cWaitBusy(regs); - if(!I2C_GET_ACK(regs->REG_I2C_CNT)) // If ack flag is 0 it failed. - { - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_ERROR | I2C_STOP; - continue; - } - - // Select register and change direction to write. - regs->REG_I2C_DATA = regAddr; - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_DIRE_WRITE; - i2cWaitBusy(regs); - if(!I2C_GET_ACK(regs->REG_I2C_CNT)) // If ack flag is 0 it failed. - { - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_ERROR | I2C_STOP; - continue; - } - - // Select device in read mode for read transfer. - if(read) - { - regs->REG_I2C_DATA = devAddr | 1u; // Set bit 0 for read. - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_START; - i2cWaitBusy(regs); - if(!I2C_GET_ACK(regs->REG_I2C_CNT)) // If ack flag is 0 it failed. - { - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_ERROR | I2C_STOP; - continue; - } - } - - break; - } - - if(i < 8) return true; - else return false; -} - -bool I2C_readRegBuf(I2cDevice devId, u8 regAddr, u8 *out, u32 size) -{ - const u8 busId = i2cDevTable[devId].busId; - I2cRegs *const regs = i2cGetBusRegsBase(busId); - - - if(!i2cStartTransfer(devId, regAddr, true, regs)) return false; - - while(--size) - { - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_DIRE_READ | I2C_ACK; - i2cWaitBusy(regs); - *out++ = regs->REG_I2C_DATA; - } - - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_DIRE_READ | I2C_STOP; - i2cWaitBusy(regs); - *out = regs->REG_I2C_DATA; // Last byte - - return true; -} - -bool I2C_writeRegBuf(I2cDevice devId, u8 regAddr, const u8 *in, u32 size) -{ - const u8 busId = i2cDevTable[devId].busId; - I2cRegs *const regs = i2cGetBusRegsBase(busId); - - - if(!i2cStartTransfer(devId, regAddr, false, regs)) return false; - - while(--size) - { - regs->REG_I2C_DATA = *in++; - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_DIRE_WRITE; - i2cWaitBusy(regs); - if(!I2C_GET_ACK(regs->REG_I2C_CNT)) // If ack flag is 0 it failed. - { - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_ERROR | I2C_STOP; - return false; - } - } - - regs->REG_I2C_DATA = *in; - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_DIRE_WRITE | I2C_STOP; - i2cWaitBusy(regs); - if(!I2C_GET_ACK(regs->REG_I2C_CNT)) // If ack flag is 0 it failed. - { - regs->REG_I2C_CNT = I2C_ENABLE | I2C_IRQ_ENABLE | I2C_ERROR | I2C_STOP; - return false; - } - - return true; -} - -u8 I2C_readReg(I2cDevice devId, u8 regAddr) -{ - u8 data; - if(!I2C_readRegBuf(devId, regAddr, &data, 1)) return 0xFF; - return data; -} - -bool I2C_writeReg(I2cDevice devId, u8 regAddr, u8 data) -{ - return I2C_writeRegBuf(devId, regAddr, &data, 1); -} diff --git a/exceptions/arm9/source/i2c.h b/exceptions/arm9/source/i2c.h deleted file mode 100644 index ea94422..0000000 --- a/exceptions/arm9/source/i2c.h +++ /dev/null @@ -1,102 +0,0 @@ -#pragma once - -/* - * This file is part of fastboot 3DS - * Copyright (C) 2017 derrek, profi200 - * - * 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 3 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 "types.h" - - -#define I2C_STOP (1u) -#define I2C_START (1u<<1) -#define I2C_ERROR (1u<<2) -#define I2C_ACK (1u<<4) -#define I2C_DIRE_WRITE (0u) -#define I2C_DIRE_READ (1u<<5) -#define I2C_IRQ_ENABLE (1u<<6) -#define I2C_ENABLE (1u<<7) - -#define I2C_GET_ACK(reg) ((bool)((reg)>>4 & 1u)) - - -typedef enum -{ - I2C_DEV_POWER = 0, // Unconfirmed - I2C_DEV_CAMERA = 1, // Unconfirmed - I2C_DEV_CAMERA2 = 2, // Unconfirmed - I2C_DEV_MCU = 3, - I2C_DEV_GYRO = 10, - I2C_DEV_DEBUG_PAD = 12, - I2C_DEV_IR = 13, - I2C_DEV_EEPROM = 14, // Unconfirmed - I2C_DEV_NFC = 15, - I2C_DEV_QTM = 16, - I2C_DEV_N3DS_HID = 17 -} I2cDevice; - - - -/** - * @brief Initializes the I2C buses. Call this only once. - */ -void I2C_init(void); - -/** - * @brief Reads data from a I2C register to a buffer. - * - * @param[in] devId The device ID. Use the enum above. - * @param[in] regAddr The register address. - * @param out The output buffer pointer. - * @param[in] size The read size. - * - * @return Returns true on success and false on failure. - */ -bool I2C_readRegBuf(I2cDevice devId, u8 regAddr, u8 *out, u32 size); - -/** - * @brief Writes a buffer to a I2C register. - * - * @param[in] devId The device ID. Use the enum above. - * @param[in] regAddr The register address. - * @param[in] in The input buffer pointer. - * @param[in] size The write size. - * - * @return Returns true on success and false on failure. - */ -bool I2C_writeRegBuf(I2cDevice devId, u8 regAddr, const u8 *in, u32 size); - -/** - * @brief Reads a byte from a I2C register. - * - * @param[in] devId The device ID. Use the enum above. - * @param[in] regAddr The register address. - * - * @return Returns the value read on success otherwise 0xFF. - */ -u8 I2C_readReg(I2cDevice devId, u8 regAddr); - -/** - * @brief Writes a byte to a I2C register. - * - * @param[in] devId The device ID. Use the enum above. - * @param[in] regAddr The register address. - * @param[in] data The data to write. - * - * @return Returns true on success and false on failure. - */ -bool I2C_writeReg(I2cDevice devId, u8 regAddr, u8 data); diff --git a/exceptions/arm9/source/start.s b/exceptions/arm9/source/start.s deleted file mode 100644 index 75f6240..0000000 --- a/exceptions/arm9/source/start.s +++ /dev/null @@ -1,39 +0,0 @@ -@ This file is part of Luma3DS -@ Copyright (C) 2016-2019 Aurora Wright, TuxSH -@ -@ 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 3 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 . -@ -@ Additional Terms 7.b and 7.c of GPLv3 apply to this file: -@ * Requiring preservation of specified reasonable legal notices or -@ author attributions in that material or in the Appropriate Legal -@ Notices displayed by works containing it. -@ * Prohibiting misrepresentation of the origin of that material, -@ or requiring that modified versions of such material be marked in -@ reasonable ways as different from the original version. - -.section .text.start -.align 4 -.global _start -_start: - add pc, r0, #(handlers - .) @ Dummy instruction - -.global BreakPtr -BreakPtr: .word 0 - -.global handlers -handlers: - .word FIQHandler - .word undefinedInstructionHandler - .word prefetchAbortHandler - .word dataAbortHandler diff --git a/sysmodules/rosalina/Makefile b/sysmodules/rosalina/Makefile index e6339e7..bf925e4 100644 --- a/sysmodules/rosalina/Makefile +++ b/sysmodules/rosalina/Makefile @@ -18,9 +18,9 @@ include $(DEVKITARM)/3ds_rules #--------------------------------------------------------------------------------- TARGET := $(notdir $(CURDIR)) BUILD := build -SOURCES := source source/gdb source/menus +SOURCES := source source/gdb source/menus source/redshift DATA := source/gdb/xml -INCLUDES := include include/gdb include/menus +INCLUDES := include include/gdb include/menus include/redshift #--------------------------------------------------------------------------------- # options for code generation @@ -39,7 +39,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 ASFLAGS := -g $(ARCH) LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map),--section-start,.text=0x14000000 -LIBS := -lctru +LIBS := -lctru -lm #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing