Cleanup
This commit is contained in:
parent
5202ba8826
commit
a736e4602a
@ -12,6 +12,6 @@
|
|||||||
#define MULTICONFIG(a) ((config >> (a * 2 + 6)) & 3)
|
#define MULTICONFIG(a) ((config >> (a * 2 + 6)) & 3)
|
||||||
#define BOOTCONFIG(a, b) ((config >> a) & b)
|
#define BOOTCONFIG(a, b) ((config >> a) & b)
|
||||||
|
|
||||||
extern u32 config;
|
extern u32 config;
|
||||||
|
|
||||||
void configureCFW(const char *configPath);
|
void configureCFW(const char *configPath);
|
@ -9,7 +9,7 @@
|
|||||||
#include "fatfs/sdmmc/sdmmc.h"
|
#include "fatfs/sdmmc/sdmmc.h"
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* Crypto Libs
|
* Crypto libs
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
/* original version by megazig */
|
/* original version by megazig */
|
||||||
@ -271,7 +271,7 @@ static void sha(void *res, const void *src, u32 size, u32 mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* Nand/FIRM Crypto stuff
|
* NAND/FIRM crypto
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
static u8 nandCTR[0x10],
|
static u8 nandCTR[0x10],
|
||||||
|
@ -22,6 +22,7 @@ static const struct fb {
|
|||||||
static inline int strlen(const char *string)
|
static inline int strlen(const char *string)
|
||||||
{
|
{
|
||||||
char *stringEnd = (char *)string;
|
char *stringEnd = (char *)string;
|
||||||
|
|
||||||
while(*stringEnd) stringEnd++;
|
while(*stringEnd) stringEnd++;
|
||||||
|
|
||||||
return stringEnd - string;
|
return stringEnd - string;
|
||||||
@ -43,7 +44,7 @@ void loadSplash(void)
|
|||||||
fileRead(fb->bottom, "/luma/splashbottom.bin", 0x38400))
|
fileRead(fb->bottom, "/luma/splashbottom.bin", 0x38400))
|
||||||
{
|
{
|
||||||
u64 i = 0x1400000;
|
u64 i = 0x1400000;
|
||||||
while(--i) __asm("mov r0, r0"); //Less Ghetto sleep func
|
while(i--) __asm("mov r0, r0"); //Less Ghetto sleep func
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define NCSD_MAGIC (0x4453434E)
|
#define NCSD_MAGIC 0x4453434E
|
||||||
|
|
||||||
void getEmunandSect(u32 *off, u32 *head, u32 *emuNAND);
|
void getEmunandSect(u32 *off, u32 *head, u32 *emuNAND);
|
||||||
u32 getSDMMC(u8 *pos, u32 size);
|
u32 getSDMMC(u8 *pos, u32 size);
|
||||||
|
@ -138,7 +138,6 @@ void main(void)
|
|||||||
//If screens are inited or the corresponding option is set, load splash screen
|
//If screens are inited or the corresponding option is set, load splash screen
|
||||||
if(PDN_GPU_CNT != 1 || CONFIG(8)) loadSplash();
|
if(PDN_GPU_CNT != 1 || CONFIG(8)) loadSplash();
|
||||||
|
|
||||||
//Determine if we need to autoboot sysNAND
|
|
||||||
u32 autoBootSys = CONFIG(0);
|
u32 autoBootSys = CONFIG(0);
|
||||||
|
|
||||||
//Determine if we need to boot an emuNAND or sysNAND
|
//Determine if we need to boot an emuNAND or sysNAND
|
||||||
@ -187,7 +186,6 @@ void main(void)
|
|||||||
launchFirm(bootType);
|
launchFirm(bootType);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load FIRM into FCRAM
|
|
||||||
static inline void loadFirm(u32 firmType, u32 externalFirm)
|
static inline void loadFirm(u32 firmType, u32 externalFirm)
|
||||||
{
|
{
|
||||||
section = firm->section;
|
section = firm->section;
|
||||||
@ -390,7 +388,7 @@ static inline void patchTwlAgbFirm(u32 firmType)
|
|||||||
|
|
||||||
static inline void launchFirm(u32 bootType)
|
static inline void launchFirm(u32 bootType)
|
||||||
{
|
{
|
||||||
//Copy firm partitions to respective memory locations
|
//Copy FIRM sections to respective memory locations
|
||||||
for(u32 i = 0; i < 4 && section[i].size; i++)
|
for(u32 i = 0; i < 4 && section[i].size; i++)
|
||||||
memcpy(section[i].address, (u8 *)firm + section[i].offset, section[i].size);
|
memcpy(section[i].address, (u8 *)firm + section[i].offset, section[i].size);
|
||||||
|
|
||||||
|
26
source/i2c.c
26
source/i2c.c
@ -22,26 +22,26 @@ static inline u8 i2cGetDeviceRegAddr(u8 device_id)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static vu8* reg_data_addrs[] = {
|
static vu8 *reg_data_addrs[] = {
|
||||||
(vu8*)(I2C1_REG_OFF + I2C_REG_DATA),
|
(vu8 *)(I2C1_REG_OFF + I2C_REG_DATA),
|
||||||
(vu8*)(I2C2_REG_OFF + I2C_REG_DATA),
|
(vu8 *)(I2C2_REG_OFF + I2C_REG_DATA),
|
||||||
(vu8*)(I2C3_REG_OFF + I2C_REG_DATA),
|
(vu8 *)(I2C3_REG_OFF + I2C_REG_DATA),
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline vu8* i2cGetDataReg(u8 bus_id)
|
static inline vu8 *i2cGetDataReg(u8 bus_id)
|
||||||
{
|
{
|
||||||
return reg_data_addrs[bus_id];
|
return reg_data_addrs[bus_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static vu8* reg_cnt_addrs[] = {
|
static vu8 *reg_cnt_addrs[] = {
|
||||||
(vu8*)(I2C1_REG_OFF + I2C_REG_CNT),
|
(vu8 *)(I2C1_REG_OFF + I2C_REG_CNT),
|
||||||
(vu8*)(I2C2_REG_OFF + I2C_REG_CNT),
|
(vu8 *)(I2C2_REG_OFF + I2C_REG_CNT),
|
||||||
(vu8*)(I2C3_REG_OFF + I2C_REG_CNT),
|
(vu8 *)(I2C3_REG_OFF + I2C_REG_CNT),
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline vu8* i2cGetCntReg(u8 bus_id)
|
static inline vu8 *i2cGetCntReg(u8 bus_id)
|
||||||
{
|
{
|
||||||
return reg_cnt_addrs[bus_id];
|
return reg_cnt_addrs[bus_id];
|
||||||
}
|
}
|
||||||
@ -94,16 +94,16 @@ u32 i2cWriteRegister(u8 dev_id, u8 reg, u8 data)
|
|||||||
u8 bus_id = i2cGetDeviceBusId(dev_id);
|
u8 bus_id = i2cGetDeviceBusId(dev_id);
|
||||||
u8 dev_addr = i2cGetDeviceRegAddr(dev_id);
|
u8 dev_addr = i2cGetDeviceRegAddr(dev_id);
|
||||||
|
|
||||||
for (u32 i = 0; i < 8; i++)
|
for(u32 i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
if (i2cSelectDevice(bus_id, dev_addr) && i2cSelectRegister(bus_id, reg))
|
if(i2cSelectDevice(bus_id, dev_addr) && i2cSelectRegister(bus_id, reg))
|
||||||
{
|
{
|
||||||
i2cWaitBusy(bus_id);
|
i2cWaitBusy(bus_id);
|
||||||
*i2cGetDataReg(bus_id) = data;
|
*i2cGetDataReg(bus_id) = data;
|
||||||
*i2cGetCntReg(bus_id) = 0xC1;
|
*i2cGetCntReg(bus_id) = 0xC1;
|
||||||
i2cStop(bus_id, 0);
|
i2cStop(bus_id, 0);
|
||||||
|
|
||||||
if (i2cGetResult(bus_id))
|
if(i2cGetResult(bus_id))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
*i2cGetCntReg(bus_id) = 0xC5;
|
*i2cGetCntReg(bus_id) = 0xC5;
|
||||||
|
@ -11,11 +11,9 @@
|
|||||||
|
|
||||||
const u32 mpuPatch[3] = {0x00360003, 0x00200603, 0x001C0603};
|
const u32 mpuPatch[3] = {0x00360003, 0x00200603, 0x001C0603};
|
||||||
|
|
||||||
const u16 nandRedir[2] = {0x4C00, 0x47A0};
|
const u16 nandRedir[2] = {0x4C00, 0x47A0},
|
||||||
|
sigPatch[2] = {0x2000, 0x4770},
|
||||||
const u16 sigPatch[2] = {0x2000, 0x4770};
|
writeBlock[2] = {0x2000, 0x46C0};
|
||||||
|
|
||||||
const u16 writeBlock[2] = {0x2000, 0x46C0};
|
|
||||||
|
|
||||||
const u8 unitInfoPatch = 0xE3;
|
const u8 unitInfoPatch = 0xE3;
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
* Patches
|
* Patches
|
||||||
**************************************************/
|
**************************************************/
|
||||||
const u32 mpuPatch[3];
|
const u32 mpuPatch[3];
|
||||||
const u16 nandRedir[2];
|
const u16 nandRedir[2],
|
||||||
const u16 sigPatch[2];
|
sigPatch[2],
|
||||||
const u16 writeBlock[2];
|
writeBlock[2];
|
||||||
const u8 unitInfoPatch;
|
const u8 unitInfoPatch;
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
|
Reference in New Issue
Block a user