]> Chaos Git - corbenik/corbenik.git/commitdiff
Reformat
authorchaoskagami <chaos.kagami@gmail.com>
Mon, 23 May 2016 23:59:13 +0000 (19:59 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Mon, 23 May 2016 23:59:13 +0000 (19:59 -0400)
Makefile
external/loader/source/patcher.c
host/compile_header.c
source/fatfs/ff.c
source/fatfs/ff.h
source/fatfs/sdmmc.c

index 66e556c45ce44ef886cc028e6a1ee9fa308cfdeb..f22430fcba82cf26fc42cf495cadf4ba01f490c4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ a9lh: $(dir_out)/arm9loaderhax.bin
 
 .PHONY: reformat
 reformat:
-       clang-format -i $(dir_source)/*.{c,h} $(dir_source)/*/*.{c,h} external/loader/source/*.{c,h} external/loader/source/*/*.{c,h}
+       clang-format -i $(dir_source)/*.{c,h} $(dir_source)/*/*.{c,h} external/loader/source/*.{c,h} external/loader/source/*/*.{c,h} host/*.c
 
 host/langemu.conf:
        echo "Generating langemu.conf - may take a bit"
index c38e166f9c32f5b262fe369bbed0759fed95409f..6000e4983658a3508519fb34f6ef5b16552e53e3 100644 (file)
@@ -367,8 +367,8 @@ patchCfgGetLanguage(u8* code, u32 size, u8 languageId,
                             0xE3A00000 | languageId; // mov    r0, sp
                                                      // => mov r0, =languageId
                         *(u32*)instr = 0xE5CD0000;   // bl
-                                                   // CFGU_GetConfigInfoBlk2 =>
-                                                   // strb r0, [sp]
+                        // CFGU_GetConfigInfoBlk2 =>
+                        // strb r0, [sp]
                         *((u32*)instr + 1) =
                             0xE3B00000; // (1 or 2 instructions)         => movs
                                         // r0, 0             (result code)
index 8ec44546625d72b3f9057e09ee5ae95b304d3cea..f912dda6bd4f400203f11a3fc7f394d153ae16d8 100644 (file)
 
 #include "../source/patch_format.h"
 
-void read_file_u64(char* name, uint64_t* to) {
-       FILE* hdl = fopen(name, "rb");
-       fscanf(hdl, "%llu", to);
-       fclose(hdl);
+void
+read_file_u64(char* name, uint64_t* to)
+{
+    FILE* hdl = fopen(name, "rb");
+    fscanf(hdl, "%llu", to);
+    fclose(hdl);
 }
 
-
-void read_file_u32(char* name, uint32_t* to) {
-       FILE* hdl = fopen(name, "rb");
-       fscanf(hdl, "%u", to);
-       fclose(hdl);
+void
+read_file_u32(char* name, uint32_t* to)
+{
+    FILE* hdl = fopen(name, "rb");
+    fscanf(hdl, "%u", to);
+    fclose(hdl);
 }
 
-void read_str(char* name, char* to, size_t len) {
-       FILE* hdl = fopen(name, "rb");
-       int r = fread(to, 1, len-1, hdl);
-       fclose(hdl);
-
-       for(int i=len-1; i >= 0; i--) {
-               if (to[i] == '\n') {
-                       to[i] = 0;
-                       break;
-               }
-       }
+void
+read_str(char* name, char* to, size_t len)
+{
+    FILE* hdl = fopen(name, "rb");
+    int r = fread(to, 1, len - 1, hdl);
+    fclose(hdl);
+
+    for (int i = len - 1; i >= 0; i--) {
+        if (to[i] == '\n') {
+            to[i] = 0;
+            break;
+        }
+    }
 }
 
 uint32_t size = 0;
 
-uint8_t* read_file_mem(char* name) {
-       FILE* hdl = fopen(name, "rb");
+uint8_t*
+read_file_mem(char* name)
+{
+    FILE* hdl = fopen(name, "rb");
 
-       fseek(hdl, 0, SEEK_END);
-       size = ftell(hdl);
-       rewind(hdl);
+    fseek(hdl, 0, SEEK_END);
+    size = ftell(hdl);
+    rewind(hdl);
 
-       uint8_t* mem = malloc(size);
-       memset(mem, 0, size);
+    uint8_t* mem = malloc(size);
+    memset(mem, 0, size);
 
-       int r = fread(mem, 1, size, hdl);
-       fclose(hdl);
+    int r = fread(mem, 1, size, hdl);
+    fclose(hdl);
 
-       return mem;
+    return mem;
 }
 
-int main(int c, char** v) {
-       struct system_patch patch;
-       int at = 0;
+int
+main(int c, char** v)
+{
+    struct system_patch patch;
+    int at = 0;
 
-       memset(&patch, 0, sizeof(patch));
+    memset(&patch, 0, sizeof(patch));
 
-       // Set magic.
-       patch.magic[0] = 'A';
-       patch.magic[1] = 'I';
-       patch.magic[2] = 'D';
-       patch.magic[3] = 'A';
+    // Set magic.
+    patch.magic[0] = 'A';
+    patch.magic[1] = 'I';
+    patch.magic[2] = 'D';
+    patch.magic[3] = 'A';
 
-       read_file_u32("meta/patch_version", & patch.patch_ver);
-       read_file_u32("meta/cfw_version", & patch.load_ver);
+    read_file_u32("meta/patch_version", &patch.patch_ver);
+    read_file_u32("meta/cfw_version", &patch.load_ver);
 
-       read_file_u64("meta/uuid", & patch.patch_id);
-       read_file_u64("meta/title", & patch.tid);
+    read_file_u64("meta/uuid", &patch.patch_id);
+    read_file_u64("meta/title", &patch.tid);
 
-       read_str("meta/name", patch.name, sizeof(patch.name));
-       read_str("meta/desc", patch.desc, sizeof(patch.desc));
+    read_str("meta/name", patch.name, sizeof(patch.name));
+    read_str("meta/desc", patch.desc, sizeof(patch.desc));
 
-       uint8_t* code = read_file_mem("out/patch.bin");
+    uint8_t* code = read_file_mem("out/patch.bin");
 
-       patch.patch_size = size;
+    patch.patch_size = size;
 
-       FILE* out = fopen("out/patch.vco", "wb");
-       fwrite(&patch, 1, sizeof(patch),    out);
-       fwrite(code,   1, patch.patch_size, out);
-       fclose(out);
+    FILE* out = fopen("out/patch.vco", "wb");
+    fwrite(&patch, 1, sizeof(patch), out);
+    fwrite(code, 1, patch.patch_size, out);
+    fclose(out);
 
-       free(code);
+    free(code);
 
-       printf("Ver:  %u\n"
-                       "CFW:  %u\n"
-                       "UUID: %llu\n"
-                       "TID:  %llu\n"
-                       "Name: %s\n"
-                       "Desc: %s\n"
-                       "Size: %u\n",
-                       patch.patch_ver, patch.load_ver, patch.patch_id,
-                       patch.tid, patch.name, patch.desc, patch.patch_size);
+    printf("Ver:  %u\n"
+           "CFW:  %u\n"
+           "UUID: %llu\n"
+           "TID:  %llu\n"
+           "Name: %s\n"
+           "Desc: %s\n"
+           "Size: %u\n",
+           patch.patch_ver, patch.load_ver, patch.patch_id, patch.tid,
+           patch.name, patch.desc, patch.patch_size);
 
-       return 0;
+    return 0;
 }
index ed60feeb37610fc6c257d458842fe4a27ae240db..80c112c6db8b9d3cdf6d798edefaf48c812cce2d 100644 (file)
@@ -852,9 +852,8 @@ chk_lock(         /* Check if the file can be accessed */
     for (i = be = 0; i < _FS_LOCK; i++) {
         if (Files[i].fs) { /* Existing entry */
             if (Files[i].fs ==
-                    dp
-                        ->fs && /* Check if the object matched with an open
-                                   object */
+                    dp->fs && /* Check if the object matched with an open
+                                 object */
                 Files[i].clu == dp->sclust &&
                 Files[i].idx == dp->index)
                 break;
@@ -885,10 +884,9 @@ static int enq_lock(void) /* Check if an entry is available for a new object */
 static UINT
 inc_lock(/* Increment object open counter and returns its index (0:Internal
             error) */
-         DIR*
-             dp, /* Directory object pointing the file to register or increment
-                    */
-         int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */
+         DIR* dp, /* Directory object pointing the file to register or increment
+                     */
+         int acc  /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */
          )
 {
     UINT i;
@@ -1371,9 +1369,8 @@ dir_sdi(DIR* dp, /* Pointer to directory object */
             if (clst == 0xFFFFFFFF)
                 return FR_DISK_ERR; /* Disk error */
             if (clst < 2 ||
-                clst >=
-                    dp->fs->n_fatent) /* Reached to end of table or internal
-                                         error */
+                clst >= dp->fs->n_fatent) /* Reached to end of table or internal
+                                             error */
                 return FR_INT_ERR;
             idx -= ic;
         }
@@ -2076,9 +2073,8 @@ get_fileinfo(             /* No return code */
                     break;
                 } /* No LFN if it could not be converted */
                 if (_DF1S &&
-                    w >=
-                        0x100) /* Put 1st byte if it is a DBC (always false on
-                                  SBCS cfg) */
+                    w >= 0x100) /* Put 1st byte if it is a DBC (always false on
+                                   SBCS cfg) */
                     p[i++] = (TCHAR)(w >> 8);
 #endif
                 if (i >= fno->lfsize - 1) {
@@ -2203,9 +2199,8 @@ create_name(DIR* dp, /* Pointer to the directory object */
             return FR_INVALID_NAME;
 #if !_LFN_UNICODE
         w &= 0xFF;
-        if (IsDBCS1(
-                w)) { /* Check if it is a DBC 1st byte (always false on SBCS
-                         cfg) */
+        if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS
+                             cfg) */
             b = (BYTE)p[si++]; /* Get 2nd byte */
             w = (w << 8) + b;  /* Create a DBC */
             if (!IsDBCS2(b))
@@ -2319,9 +2314,8 @@ create_name(DIR* dp, /* Pointer to the directory object */
     }
 
     if (dp->fn[0] == DDEM)
-        dp
-            ->fn[0] = RDDEM; /* If the first character collides with deleted
-                                mark, replace it with RDDEM */
+        dp->fn[0] = RDDEM; /* If the first character collides with deleted
+                              mark, replace it with RDDEM */
 
     if (ni == 8)
         b <<= 2;
@@ -2392,9 +2386,8 @@ create_name(DIR* dp, /* Pointer to the directory object */
 #endif
 #endif
         }
-        if (IsDBCS1(
-                c)) { /* Check if it is a DBC 1st byte (always false on SBCS
-                         cfg) */
+        if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS
+                             cfg) */
             d = (BYTE)p[si++];              /* Get 2nd byte */
             if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */
                 return FR_INVALID_NAME;
@@ -2536,9 +2529,8 @@ get_ldnumber(/* Returns logical drive number (-1:invalid drive) */
             tp = *path;
             i = *tp++ - '0';
             if (i < 10 && tp == tt) { /* Is there a numeric drive id? */
-                if (i <
-                    _VOLUMES) { /* If a drive id is found, get the value and
-                                   strip it */
+                if (i < _VOLUMES) { /* If a drive id is found, get the value and
+                                       strip it */
                     vol = (int)i;
                     *path = ++tt;
                 }
@@ -2559,10 +2551,9 @@ get_ldnumber(/* Returns logical drive number (-1:invalid drive) */
                 } while (
                     (c || tp != tt) &&
                     ++i <
-                        _VOLUMES); /* Repeat for each id until pattern match */
-                if (i <
-                    _VOLUMES) { /* If a drive id is found, get the value and
-                                   strip it */
+                        _VOLUMES);  /* Repeat for each id until pattern match */
+                if (i < _VOLUMES) { /* If a drive id is found, get the value and
+                                       strip it */
                     vol = (int)i;
                     *path = tt;
                 }
@@ -2587,9 +2578,8 @@ static BYTE
 check_fs(/* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot
             sector, 3:Disk error */
          FATFS* fs, /* File system object */
-         DWORD
-             sect /* Sector# (lba) to check if it is an FAT boot record or not
-                     */
+         DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not
+                       */
          )
 {
     fs->wflag = 0;
@@ -3446,10 +3436,9 @@ f_getcwd(TCHAR* buff, /* Pointer to the directory path */
     res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */
     if (res == FR_OK) {
         INIT_BUF(dj);
-        i = len; /* Bottom of buffer (directory stack base) */
-        dj.sclust =
-            dj.fs->cdir; /* Start to follow upper directory from current
-                            directory */
+        i = len;                 /* Bottom of buffer (directory stack base) */
+        dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current
+                                    directory */
         while ((ccl = dj.sclust) !=
                0) { /* Repeat while current directory is a sub-directory */
             res = dir_sdi(&dj, 1); /* Get parent directory */
@@ -3612,9 +3601,8 @@ f_lseek(FIL* fp,  /* Pointer to the file object */
 
     /* Normal Seek */
     {
-        if (ofs >
-                fp->fsize /* In read-only mode, clip offset with the file size
-                             */
+        if (ofs > fp->fsize /* In read-only mode, clip offset with the file size
+                               */
 #if !_FS_READONLY
             && !(fp->flag & FA_WRITE)
 #endif
@@ -3661,9 +3649,8 @@ f_lseek(FIL* fp,  /* Pointer to the file object */
                         }
                     } else
 #endif
-                        clst =
-                            get_fat(fp->fs, clst); /* Follow cluster chain if
-                                                      not in write mode */
+                        clst = get_fat(fp->fs, clst); /* Follow cluster chain if
+                                                         not in write mode */
                     if (clst == 0xFFFFFFFF)
                         ABORT(fp->fs, FR_DISK_ERR);
                     if (clst <= 1 || clst >= fp->fs->n_fatent)
index 31960b4f5694366df6e6fd42adfc63644917cfd2..2fe5e6a12c5989f15e27db795662ef2935dccdc1 100644 (file)
@@ -117,7 +117,7 @@ typedef struct
     DWORD fptr;  /* File read/write pointer (Zeroed on file open) */
     DWORD fsize; /* File size */
     DWORD
-        sclust;  /* File start cluster (0:no cluster chain, always 0 when fsize
+    sclust;      /* File start cluster (0:no cluster chain, always 0 when fsize
                     is 0) */
     DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */
     DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */
index 79d5cbe0d658ca1a33629d276d3724d4f711ffce..d249a570c1cd9bc5a3a0b493bf192d1beb74308d 100644 (file)
@@ -394,37 +394,37 @@ InitSD()
 #ifdef DATA32_SUPPORT
     *(volatile uint16_t*)0x10006100 |= 0x402u; // SDDATACTL32
 #else
-    *(volatile uint16_t*)0x10006100 |= 0x402u; // SDDATACTL32
+    *(volatile uint16_t*)0x10006100 |= 0x402u;  // SDDATACTL32
 #endif
     *(volatile uint16_t*)0x100060D8 =
         (*(volatile uint16_t*)0x100060D8 & 0xFFDD) | 2;
 #ifdef DATA32_SUPPORT
     *(volatile uint16_t*)0x10006100 &= 0xFFFFu; // SDDATACTL32
     *(volatile uint16_t*)0x100060D8 &= 0xFFDFu; // SDDATACTL
-    *(volatile uint16_t*)0x10006104 = 512; // SDBLKLEN32
+    *(volatile uint16_t*)0x10006104 = 512;      // SDBLKLEN32
 #else
     *(volatile uint16_t*)0x10006100 &= 0xFFFDu; // SDDATACTL32
     *(volatile uint16_t*)0x100060D8 &= 0xFFDDu; // SDDATACTL
-    *(volatile uint16_t*)0x10006104 = 0; // SDBLKLEN32
+    *(volatile uint16_t*)0x10006104 = 0;        // SDBLKLEN32
 #endif
-    *(volatile uint16_t*)0x10006108 = 1; // SDBLKCOUNT32
-    *(volatile uint16_t*)0x100060E0 &= 0xFFFEu; // SDRESET
-    *(volatile uint16_t*)0x100060E0 |= 1u; // SDRESET
-    *(volatile uint16_t*)0x10006020 |= TMIO_MASK_ALL; // SDIR_MASK0
+    *(volatile uint16_t*)0x10006108 = 1;                    // SDBLKCOUNT32
+    *(volatile uint16_t*)0x100060E0 &= 0xFFFEu;             // SDRESET
+    *(volatile uint16_t*)0x100060E0 |= 1u;                  // SDRESET
+    *(volatile uint16_t*)0x10006020 |= TMIO_MASK_ALL;       // SDIR_MASK0
     *(volatile uint16_t*)0x10006022 |= TMIO_MASK_ALL >> 16; // SDIR_MASK1
-    *(volatile uint16_t*)0x100060FC |= 0xDBu; // SDCTL_RESERVED7
-    *(volatile uint16_t*)0x100060FE |= 0xDBu; // SDCTL_RESERVED8
-    *(volatile uint16_t*)0x10006002 &= 0xFFFCu; // SDPORTSEL
+    *(volatile uint16_t*)0x100060FC |= 0xDBu;               // SDCTL_RESERVED7
+    *(volatile uint16_t*)0x100060FE |= 0xDBu;               // SDCTL_RESERVED8
+    *(volatile uint16_t*)0x10006002 &= 0xFFFCu;             // SDPORTSEL
 #ifdef DATA32_SUPPORT
     *(volatile uint16_t*)0x10006024 = 0x20;
     *(volatile uint16_t*)0x10006028 = 0x40EE;
 #else
-    *(volatile uint16_t*)0x10006024 = 0x40; // Nintendo sets this to 0x20
-    *(volatile uint16_t*)0x10006028 = 0x40EB; // Nintendo sets this to 0x40EE
+    *(volatile uint16_t*)0x10006024 = 0x40;     // Nintendo sets this to 0x20
+    *(volatile uint16_t*)0x10006028 = 0x40EB;   // Nintendo sets this to 0x40EE
 #endif
     *(volatile uint16_t*)0x10006002 &= 0xFFFCu; ////SDPORTSEL
-    *(volatile uint16_t*)0x10006026 = 512; // SDBLKLEN
-    *(volatile uint16_t*)0x10006008 = 0; // SDSTOP
+    *(volatile uint16_t*)0x10006026 = 512;      // SDBLKLEN
+    *(volatile uint16_t*)0x10006008 = 0;        // SDSTOP
 
     inittarget(&handelSD);
 }
@@ -574,11 +574,11 @@ SD_Init()
     // sdmmc_send_command(&handelSD,0x10769,0x00FF8000 | temp);
     //
     // DEBUGPRINT(topScreen, "sd error ", handelSD.error, 10, 20 + 17*8,
-    //RGB(40, 40, 40), RGB(208, 208, 208));
+    // RGB(40, 40, 40), RGB(208, 208, 208));
     // DEBUGPRINT(topScreen, "sd ret: ", handelSD.ret[0], 10, 20 + 18*8,
-    //RGB(40, 40, 40), RGB(208, 208, 208));
+    // RGB(40, 40, 40), RGB(208, 208, 208));
     // DEBUGPRINT(topScreen, "count: ", count++, 10, 20 + 19*8, RGB(40, 40,
-    //40), RGB(208, 208, 208));
+    // 40), RGB(208, 208, 208));
     //}
     // while(!(handelSD.ret[0] & 0x80000000));