#include <stdint.h>
#include <stddef.h>
+#include <string.h>
-size_t strlen(char *string);
-void memcpy(void *dest, const void *src, size_t size);
-void memmove(void *dest, const void *src, size_t size);
-void memset(void *dest, const int filler, size_t size);
-int memcmp(const void *buf1, const void *buf2, const size_t size);
-void strncpy(void *dest, const void *src, const size_t size);
-int strncmp(const void *buf1, const void *buf2, const size_t size);
int atoi(const char *str);
uint8_t *memfind(uint8_t *startPos, uint32_t size, const void *pattern, uint32_t patternSize);
int isprint(char c);
-size_t strnlen(const char *string, size_t maxlen);
#endif
{ OPTION_EMUNAND, "Use EmuNAND", "Redirects NAND write/read to the SD. This supports both Gateway and redirected layouts.", boolean_val, 0, 0, 0 },
{ OPTION_EMUNAND_INDEX, "Index", "Which EmuNAND to use. If you only have one, you want 0. Currently the maximum supported is 10 (0-9), but this is arbitrary.", ranged_val, 0, 0x9, 1 },
-// { OPTION_EMUNAND_REVERSE, " Reverse layout", "(Warning - Experimental!) Calculate EmuNAND sector from the end of the disk, not the start. This isn't supported by tools like Decrypt9, but has some advantages.", boolean_val, 0, 0x9 },
{ OPTION_AUTOBOOT, "Autoboot", "Boot the system automatically, unless the R key is held while booting.", boolean_val, 0, 0, 0 },
{ OPTION_SILENCE, "Silent mode", "Suppress all debug output during autoboot. You'll see the screen turn on and then off once.", boolean_val, 0, 0, 1 },
+
{ OPTION_DIM_MODE, "Dim Background", "Experimental! Dims colors on lighter backgrounds to improve readability with text. You won't notice the change until scrolling or exiting the current menu due to the way rendering works.", boolean_val, 0, 0, 0 },
{ OPTION_ACCENT_COLOR, "Accent color", "Changes the accent color in menus.", ranged_val, 1, 7, 0},
if (memcmp(p.magic, "AIDA", 4))
return;
- strncpy(patches[current_menu_index_patches].name, p.name, 64);
+ memcpy(patches[current_menu_index_patches].name, p.name, 64);
if (desc_is_fname_sto)
- strncpy(patches[current_menu_index_patches].desc, fpath, 255);
+ memcpy(patches[current_menu_index_patches].desc, fpath, 255);
else
- strncpy(patches[current_menu_index_patches].desc, p.desc, 255);
+ memcpy(patches[current_menu_index_patches].desc, p.desc, 255);
patches[current_menu_index_patches].index = (int64_t)p.uuid;
patches[current_menu_index_patches].allowed = boolean_val;
patches[current_menu_index_patches].a = 0;
bx lr
enable_mpu_and_caching:
- // Enable caches and MPU
+ // Enable caches, MPU, and itcm
mrc p15, 0, r0, c1, c0, 0 // read control register
+ orr r0, r0, #(1<<18) // - itcm enable
orr r0, r0, #(1<<12) // - instruction cache enable
orr r0, r0, #(1<<2) // - data cache enable
orr r0, r0, #(1<<0) // - mpu enable
fname++;
while (f_readdir(&pdir, &fno) == FR_OK) {
- strncpy(fname, fno.fname, strlen(fno.fname));
+ strcpy(fname, fno.fname);
if (fno.fname[0] == 0)
break;
int
rrmdir(char *name)
{
- char fpath[256];
- strncpy(fpath, name, 256);
- recurse_call(fpath, (void (*)(char*))f_unlink);
+ recurse_call(name, (void (*)(char*))f_unlink);
return 0;
}
#include <stdint.h>
#include <stddef.h>
-size_t
-strlen(char *string)
-{
- char *string_end = string;
- while (string_end[0])
- string_end++;
- return (size_t)(string_end - string);
-}
-
-size_t
-strnlen(const char *string, size_t maxlen)
-{
- size_t size;
-
- for (size = 0; *string && size < maxlen; string++, size++)
- ;
-
- return size;
-}
-
int
isprint(char c)
{
return 0;
}
-void
-memcpy(void *dest, const void *src, size_t size)
-{
- uint8_t *destc = (uint8_t *)dest;
- const uint8_t *srcc = (const uint8_t *)src;
-
- for(size_t i=0; i < size; i++) {
- destc[i] = srcc[i];
- }
-}
-
-void
-memmove(void *dest, const void *src, size_t size)
-{
- // memcpy does the job of moving backwards just fine
- if (dest < src || (const uint8_t*)src + size <= (uint8_t*)dest) {
- memcpy(dest, src, size);
- return;
- }
-
- // Moving forward is just a reverse memcpy
- uint8_t *destc = (uint8_t *)dest;
- const uint8_t *srcc = (const uint8_t *)src;
-
- // Finish by copying the leftovers
- for(size_t i=size; i > 0; i--) {
- destc[i-1] = srcc[i-1];
- }
-}
-
-void
-memset(void *dest, const int filler, size_t size)
-{
- char *destc = (char *)dest;
-
- // Finish
- for(size_t i = 0; i < size; i++) {
- destc[i] = filler;
- }
-}
-
-int
-memcmp(const void *buf1, const void *buf2, const size_t size)
-{
- const char *buf1c = (const char *)buf1;
- const char *buf2c = (const char *)buf2;
- for (size_t i = 0; i < size; i++) {
- int cmp = buf1c[i] - buf2c[i];
- if (cmp) {
- return cmp;
- }
- }
-
- return 0;
-}
-
-void
-strncpy(void *dest, const void *src, const size_t size)
-{
- char *destc = (char *)dest;
- const char *srcc = (const char *)src;
-
- size_t i;
- for (i = 0; i < size && srcc[i] != 0; i++) {
- destc[i] = srcc[i];
- }
-
- // Make sure the resulting string is terminated.
- destc[i] = 0;
-}
-
-int
-strncmp(const void *buf1, const void *buf2, const size_t size)
-{
- const char *buf1c = (const char *)buf1;
- const char *buf2c = (const char *)buf2;
-
- size_t i;
- for (i = 0; i < size && buf1c[i] != 0 && buf2c[i] != 0; i++) {
- int cmp = buf1c[i] - buf2c[i];
- if (cmp) {
- return cmp;
- }
- }
-
- // Make sure the strings end at the same offset, if they end.
- if ((buf1c[i] == 0 || buf2c[i] == 0) && (buf1c[i] != 0 || buf2c[i] != 0)) {
- return -1;
- }
-
- return 0;
-}
-
int
atoi(const char *str)
{