Revert part of 136e0d89 (due to cache issues)

This commit is contained in:
TuxSH 2016-07-03 20:53:13 +02:00
parent 53d2aac2ae
commit 575adcbb9d
3 changed files with 34 additions and 34 deletions

View File

@ -19,8 +19,6 @@
#define COLOR_RED 0x0000FF #define COLOR_RED 0x0000FF
#define COLOR_BLACK 0x000000 #define COLOR_BLACK 0x000000
extern volatile struct fb *const fb;
bool loadSplash(void); bool loadSplash(void);
void drawCharacter(char character, int posX, int posY, u32 color); void drawCharacter(char character, int posX, int posY, u32 color);
int drawString(const char *string, int posX, int posY, u32 color); int drawString(const char *string, int posX, int posY, u32 color);

View File

@ -12,17 +12,18 @@
#include "draw.h" #include "draw.h"
#include "i2c.h" #include "i2c.h"
#define ARM11_STUB_ADDRESS (0x25000000 - 0x40) //It's currently only 0x28 bytes large. We're putting 0x40 just to be sure here
#define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)();
vu32 *arm11Entry = (vu32 *)0x1FFFFFF8; vu32 *arm11Entry = (vu32 *)0x1FFFFFF8;
volatile struct fb *const fb = (volatile struct fb *)0x23FFFE00;
void __attribute__((naked)) arm11Stub(void) void __attribute__((naked)) arm11Stub(void)
{ {
//Disable interrupts //Disable interrupts
__asm(".word 0xF10C01C0"); __asm(".word 0xF10C01C0");
//Wait for the entry to be set //Wait for the entry to be set
while(*arm11Entry == ARM11_STUB_ADDRESS); while(*arm11Entry == ARM11_STUB_ADDRESS);
//Jump to it //Jump to it
((void (*)())*arm11Entry)(); ((void (*)())*arm11Entry)();
} }
@ -30,14 +31,13 @@ void __attribute__((naked)) arm11Stub(void)
static inline void invokeArm11Function(void (*func)()) static inline void invokeArm11Function(void (*func)())
{ {
static bool hasCopiedStub = false; static bool hasCopiedStub = false;
if(!hasCopiedStub) if(!hasCopiedStub)
{ {
memcpy((void *)ARM11_STUB_ADDRESS, arm11Stub, 0x40); memcpy((void *)ARM11_STUB_ADDRESS, arm11Stub, 0x40);
flushDCacheRange((void *)ARM11_STUB_ADDRESS, 0x40); flushDCacheRange((void *)ARM11_STUB_ADDRESS, 0x40);
hasCopiedStub = true; hasCopiedStub = true;
} }
*arm11Entry = (u32)func; *arm11Entry = (u32)func;
while(*arm11Entry); while(*arm11Entry);
*arm11Entry = ARM11_STUB_ADDRESS; *arm11Entry = ARM11_STUB_ADDRESS;
@ -63,23 +63,25 @@ void deinitScreens(void)
if(PDN_GPU_CNT != 1) invokeArm11Function(ARM11); if(PDN_GPU_CNT != 1) invokeArm11Function(ARM11);
} }
void updateBrightness(u32 brightnessIndex) void updateBrightness(u32 brightnessLevel)
{ {
u32 brightnessLevel = brightness[brightnessIndex]; static int brightnessValue;
brightnessValue = brightness[brightnessLevel];
void __attribute__((naked)) ARM11(void) void __attribute__((naked)) ARM11(void)
{ {
//Disable interrupts //Disable interrupts
__asm(".word 0xF10C01C0"); __asm(".word 0xF10C01C0");
//Change brightness //Change brightness
*(vu32 *)0x10202240 = brightnessLevel; *(vu32 *)0x10202240 = brightnessValue;
*(vu32 *)0x10202A40 = brightnessLevel; *(vu32 *)0x10202A40 = brightnessValue;
WAIT_FOR_ARM9(); WAIT_FOR_ARM9();
} }
flushDCacheRange(&brightnessLevel, 4); flushDCacheRange(&brightnessValue, 4);
invokeArm11Function(ARM11); invokeArm11Function(ARM11);
} }
@ -89,8 +91,9 @@ void clearScreens(void)
{ {
//Disable interrupts //Disable interrupts
__asm(".word 0xF10C01C0"); __asm(".word 0xF10C01C0");
//Setting up two simultaneous memory fills using the GPU //Setting up two simultaneous memory fills using the GPU
vu32 *REGs_PSC0 = (vu32 *)0x10400010; vu32 *REGs_PSC0 = (vu32 *)0x10400010;
REGs_PSC0[0] = (u32)fb->top_left >> 3; //Start address REGs_PSC0[0] = (u32)fb->top_left >> 3; //Start address
REGs_PSC0[1] = (u32)(fb->top_left + 0x46500) >> 3; //End address REGs_PSC0[1] = (u32)(fb->top_left + 0x46500) >> 3; //End address
@ -102,7 +105,7 @@ void clearScreens(void)
REGs_PSC1[1] = (u32)(fb->bottom + 0x38400) >> 3; //End address REGs_PSC1[1] = (u32)(fb->bottom + 0x38400) >> 3; //End address
REGs_PSC1[2] = 0; //Fill value REGs_PSC1[2] = 0; //Fill value
REGs_PSC1[3] = (2 << 8) | 1; //32-bit pattern; start REGs_PSC1[3] = (2 << 8) | 1; //32-bit pattern; start
while(!((REGs_PSC0[3] & 2) && (REGs_PSC1[3] & 2))); while(!((REGs_PSC0[3] & 2) && (REGs_PSC1[3] & 2)));
if(fb->top_right != fb->top_left) if(fb->top_right != fb->top_left)
@ -111,33 +114,33 @@ void clearScreens(void)
REGs_PSC0[1] = (u32)(fb->top_right + 0x46500) >> 3; //End address REGs_PSC0[1] = (u32)(fb->top_right + 0x46500) >> 3; //End address
REGs_PSC0[2] = 0; //Fill value REGs_PSC0[2] = 0; //Fill value
REGs_PSC0[3] = (2 << 8) | 1; //32-bit pattern; start REGs_PSC0[3] = (2 << 8) | 1; //32-bit pattern; start
while(!(REGs_PSC0[3] & 2)); while(!(REGs_PSC0[3] & 2));
} }
WAIT_FOR_ARM9(); WAIT_FOR_ARM9();
} }
flushDCacheRange((void *)fb, sizeof(struct fb)); flushDCacheRange((void *)fb, sizeof(struct fb));
invokeArm11Function(ARM11); invokeArm11Function(ARM11);
} }
bool initScreens(void) u32 initScreens(void)
{ {
bool needToInit = PDN_GPU_CNT == 1; u32 needToInit = PDN_GPU_CNT == 1;
void __attribute__((naked)) ARM11(void) void __attribute__((naked)) ARM11(void)
{ {
//Disable interrupts //Disable interrupts
__asm(".word 0xF10C01C0"); __asm(".word 0xF10C01C0");
u32 brightnessLevel = brightness[MULTICONFIG(0)]; u32 brightnessLevel = MULTICONFIG(0);
*(vu32 *)0x10141200 = 0x1007F; *(vu32 *)0x10141200 = 0x1007F;
*(vu32 *)0x10202014 = 0x00000001; *(vu32 *)0x10202014 = 0x00000001;
*(vu32 *)0x1020200C &= 0xFFFEFFFE; *(vu32 *)0x1020200C &= 0xFFFEFFFE;
*(vu32 *)0x10202240 = brightnessLevel; *(vu32 *)0x10202240 = brightness[brightnessLevel];
*(vu32 *)0x10202A40 = brightnessLevel; *(vu32 *)0x10202A40 = brightness[brightnessLevel];
*(vu32 *)0x10202244 = 0x1023E; *(vu32 *)0x10202244 = 0x1023E;
*(vu32 *)0x10202A44 = 0x1023E; *(vu32 *)0x10202A44 = 0x1023E;
@ -223,7 +226,7 @@ bool initScreens(void)
WAIT_FOR_ARM9(); WAIT_FOR_ARM9();
} }
if(needToInit) if(needToInit)
{ {
flushDCacheRange(&config, 4); flushDCacheRange(&config, 4);
@ -233,8 +236,9 @@ bool initScreens(void)
//Turn on backlight //Turn on backlight
i2cWriteRegister(I2C_DEV_MCU, 0x22, 0x2A); i2cWriteRegister(I2C_DEV_MCU, 0x22, 0x2A);
} }
else updateBrightness(MULTICONFIG(0)); else
updateBrightness(MULTICONFIG(0));
clearScreens(); clearScreens();
return needToInit; return needToInit;

View File

@ -10,16 +10,14 @@
#include "types.h" #include "types.h"
#define PDN_GPU_CNT (*(vu8 *)0x10141200) #define PDN_GPU_CNT (*(vu8 *)0x10141200)
#define ARM11_STUB_ADDRESS (0x25000000 - 0x40) //It's currently only 0x28 bytes large. We're putting 0x40 just to be sure here
#define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)();
struct fb { static volatile struct fb {
u8 *top_left; u8 *top_left;
u8 *top_right; u8 *top_right;
u8 *bottom; u8 *bottom;
}; } *const fb = (volatile struct fb *)0x23FFFE00;
void deinitScreens(void); void deinitScreens(void);
void updateBrightness(u32 brightnessIndex); void updateBrightness(u32 brightnessLevel);
void clearScreens(void); void clearScreens(void);
bool initScreens(void); u32 initScreens(void);