diff --git a/wiiu/frame_shader.h b/wiiu/frame_shader.h index ecea9a5679..ea02928fd8 100644 --- a/wiiu/frame_shader.h +++ b/wiiu/frame_shader.h @@ -43,4 +43,4 @@ extern GX2Shader frame_shader; } #endif -#endif // __FRAME_SHADER_H_ +#endif /* __FRAME_SHADER_H_ */ diff --git a/wiiu/fs/sd_fat_devoptab.c b/wiiu/fs/sd_fat_devoptab.c index d12fd2fb31..27d1647906 100644 --- a/wiiu/fs/sd_fat_devoptab.c +++ b/wiiu/fs/sd_fat_devoptab.c @@ -87,14 +87,14 @@ static sd_fat_private_t *sd_fat_get_device_data(const char *path) char name[128] = {0}; int i; - // Get the device name from the path + /* Get the device name from the path */ strncpy(name, path, 127); strtok(name, ":/"); - // Search the devoptab table for the specified device name - // NOTE: We do this manually due to a 'bug' in GetDeviceOpTab - // which ignores names with suffixes and causes names - // like "ntfs" and "ntfs1" to be seen as equals + /* Search the devoptab table for the specified device name */ + /* NOTE: We do this manually due to a 'bug' in GetDeviceOpTab */ + /* which ignores names with suffixes and causes names */ + /* like "ntfs" and "ntfs1" to be seen as equals */ for (i = 3; i < STD_MAX; i++) { devoptab = devoptab_list[i]; if (devoptab && devoptab->name) { @@ -109,11 +109,11 @@ static sd_fat_private_t *sd_fat_get_device_data(const char *path) static char *sd_fat_real_path (const char *path, sd_fat_private_t *dev) { - // Sanity check + /* Sanity check */ if (!path) return NULL; - // Move the path pointer to the start of the actual path + /* Move the path pointer to the start of the actual path */ if (strchr(path, ':') != NULL) { path = strchr(path, ':') + 1; } @@ -140,7 +140,7 @@ static int sd_fat_open_r (struct _reent *r, void *fileStruct, const char *path, sd_fat_file_state_t *file = (sd_fat_file_state_t *)fileStruct; file->dev = dev; - // Determine which mode the file is opened for + /* Determine which mode the file is opened for */ file->flags = flags; const char *mode_str; @@ -366,7 +366,7 @@ static ssize_t sd_fat_read_r (struct _reent *r, void* fd, char *ptr, size_t len) } else if(result == 0) { - //! TODO: error on read_size > 0 + /*! TODO: error on read_size > 0 */ break; } else @@ -393,7 +393,7 @@ static int sd_fat_fstat_r (struct _reent *r, void* fd, struct stat *st) OSLockMutex(file->dev->pMutex); - // Zero out the stat buffer + /* Zero out the stat buffer */ memset(st, 0, sizeof(struct stat)); FSStat__ stats; @@ -409,7 +409,7 @@ static int sd_fat_fstat_r (struct _reent *r, void* fd, struct stat *st) st->st_blocks = (stats.size + 511) >> 9; st->st_nlink = 1; - // Fill in the generic entry stats + /* Fill in the generic entry stats */ st->st_dev = stats.ent_id; st->st_uid = stats.owner_id; st->st_gid = stats.group_id; @@ -475,7 +475,7 @@ static int sd_fat_stat_r (struct _reent *r, const char *path, struct stat *st) OSLockMutex(dev->pMutex); - // Zero out the stat buffer + /* Zero out the stat buffer */ memset(st, 0, sizeof(struct stat)); char *real_path = sd_fat_real_path(path, dev); @@ -497,12 +497,12 @@ static int sd_fat_stat_r (struct _reent *r, const char *path, struct stat *st) return -1; } - // mark root also as directory + /* mark root also as directory */ st->st_mode = ((stats.flag & 0x80000000) || (strlen(dev->mount_path) + 1 == strlen(real_path)))? S_IFDIR : S_IFREG; st->st_nlink = 1; st->st_size = stats.size; st->st_blocks = (stats.size + 511) >> 9; - // Fill in the generic entry stats + /* Fill in the generic entry stats */ st->st_dev = stats.ent_id; st->st_uid = stats.owner_id; st->st_gid = stats.group_id; @@ -666,7 +666,7 @@ static int sd_fat_statvfs_r (struct _reent *r, const char *path, struct statvfs OSLockMutex(dev->pMutex); - // Zero out the stat buffer + /* Zero out the stat buffer */ memset(buf, 0, sizeof(struct statvfs)); char *real_path = sd_fat_real_path(path, dev); @@ -688,31 +688,31 @@ static int sd_fat_statvfs_r (struct _reent *r, const char *path, struct statvfs return -1; } - // File system block size + /* File system block size */ buf->f_bsize = 512; - // Fundamental file system block size + /* Fundamental file system block size */ buf->f_frsize = 512; - // Total number of blocks on file system in units of f_frsize - buf->f_blocks = size >> 9; // this is unknown + /* Total number of blocks on file system in units of f_frsize */ + buf->f_blocks = size >> 9; /* this is unknown */ - // Free blocks available for all and for non-privileged processes + /* Free blocks available for all and for non-privileged processes */ buf->f_bfree = buf->f_bavail = size >> 9; - // Number of inodes at this point in time + /* Number of inodes at this point in time */ buf->f_files = 0xffffffff; - // Free inodes available for all and for non-privileged processes + /* Free inodes available for all and for non-privileged processes */ buf->f_ffree = 0xffffffff; - // File system id + /* File system id */ buf->f_fsid = (int)dev; - // Bit mask of f_flag values. + /* Bit mask of f_flag values. */ buf->f_flag = 0; - // Maximum length of filenames + /* Maximum length of filenames */ buf->f_namemax = 255; OSUnlockMutex(dev->pMutex); @@ -824,7 +824,7 @@ static int sd_fat_dirnext_r (struct _reent *r, DIR_ITER *dirState, char *filenam return -1; } - // Fetch the current entry + /* Fetch the current entry */ strcpy(filename, dir_entry->name); if(st) @@ -848,7 +848,7 @@ static int sd_fat_dirnext_r (struct _reent *r, DIR_ITER *dirState, char *filenam return 0; } -// NTFS device driver devoptab +/* NTFS device driver devoptab */ static const devoptab_t devops_sd_fat = { NULL, /* Device name */ sizeof (sd_fat_file_state_t), @@ -884,24 +884,24 @@ static int sd_fat_add_device (const char *name, const char *mount_path, void *pC char *devpath = NULL; int i; - // Sanity check + /* Sanity check */ if (!name) { errno = EINVAL; return -1; } - // Allocate a devoptab for this device + /* Allocate a devoptab for this device */ dev = (devoptab_t *) malloc(sizeof(devoptab_t) + strlen(name) + 1); if (!dev) { errno = ENOMEM; return -1; } - // Use the space allocated at the end of the devoptab for storing the device name + /* Use the space allocated at the end of the devoptab for storing the device name */ devname = (char*)(dev + 1); strcpy(devname, name); - // create private data + /* create private data */ sd_fat_private_t *priv = (sd_fat_private_t *)malloc(sizeof(sd_fat_private_t) + strlen(mount_path) + 1); if(!priv) { free(dev); @@ -912,7 +912,7 @@ static int sd_fat_add_device (const char *name, const char *mount_path, void *pC devpath = (char*)(priv+1); strcpy(devpath, mount_path); - // setup private data + /* setup private data */ priv->mount_path = devpath; priv->pClient = pClient; priv->pCmd = pCmd; @@ -927,12 +927,12 @@ static int sd_fat_add_device (const char *name, const char *mount_path, void *pC OSInitMutex(priv->pMutex); - // Setup the devoptab + /* Setup the devoptab */ memcpy(dev, &devops_sd_fat, sizeof(devoptab_t)); dev->name = devname; dev->deviceData = priv; - // Add the device to the devoptab table (if there is a free slot) + /* Add the device to the devoptab table (if there is a free slot) */ for (i = 3; i < STD_MAX; i++) { if (devoptab_list[i] == devoptab_list[0]) { devoptab_list[i] = dev; @@ -940,11 +940,11 @@ static int sd_fat_add_device (const char *name, const char *mount_path, void *pC } } - // failure, free all memory + /* failure, free all memory */ free(priv); free(dev); - // If we reach here then there are no free slots in the devoptab table for this device + /* If we reach here then there are no free slots in the devoptab table for this device */ errno = EADDRNOTAVAIL; return -1; } @@ -955,14 +955,14 @@ static int sd_fat_remove_device (const char *path, void **pClient, void **pCmd, char name[128] = {0}; int i; - // Get the device name from the path + /* Get the device name from the path */ strncpy(name, path, 127); strtok(name, ":/"); - // Find and remove the specified device from the devoptab table - // NOTE: We do this manually due to a 'bug' in RemoveDevice - // which ignores names with suffixes and causes names - // like "ntfs" and "ntfs1" to be seen as equals + /* Find and remove the specified device from the devoptab table */ + /* NOTE: We do this manually due to a 'bug' in RemoveDevice */ + /* which ignores names with suffixes and causes names */ + /* like "ntfs" and "ntfs1" to be seen as equals */ for (i = 3; i < STD_MAX; i++) { devoptab = devoptab_list[i]; if (devoptab && devoptab->name) { @@ -995,12 +995,12 @@ int mount_sd_fat(const char *path) { int result = -1; - // get command and client + /* get command and client */ void* pClient = malloc(sizeof(FSClient)); void* pCmd = malloc(sizeof(FSCmdBlock)); if(!pClient || !pCmd) { - // just in case free if not 0 + /* just in case free if not 0 */ if(pClient) free(pClient); if(pCmd) @@ -1036,7 +1036,7 @@ int unmount_sd_fat(const char *path) free(pClient); free(pCmd); free(mountPath); - //FSShutdown(); + /* FSShutdown(); */ } return result; } diff --git a/wiiu/fs/sd_fat_devoptab.h b/wiiu/fs/sd_fat_devoptab.h index 8df487accd..1b085908ec 100644 --- a/wiiu/fs/sd_fat_devoptab.h +++ b/wiiu/fs/sd_fat_devoptab.h @@ -35,4 +35,4 @@ int unmount_sd_fat(const char *path); } #endif -#endif // __SD_FAT_DEVOPTAB_H_ +#endif /* __SD_FAT_DEVOPTAB_H_ */ diff --git a/wiiu/gx2_shader_inl.h b/wiiu/gx2_shader_inl.h index cf0a33bcab..08cf3c2c88 100644 --- a/wiiu/gx2_shader_inl.h +++ b/wiiu/gx2_shader_inl.h @@ -217,8 +217,8 @@ #define EXPORT_TYPE_POS 0x1 #define EXPORT_TYPE_PARAM 0x2 -#define EXPORT_ARRAY_BASE_POS(id) (0x3C + id) // [0, 3] -#define EXPORT_ARRAY_BASE_PARAM(id) id // [0, 31] +#define EXPORT_ARRAY_BASE_POS(id) (0x3C + id) /* [0, 3] */ +#define EXPORT_ARRAY_BASE_PARAM(id) id /* [0, 31] */ #define EXPORT_ARRAY_BASE_PIX(id) id /* exports */ @@ -340,4 +340,4 @@ #define _x30(v) _x16(v), _x8(v), _x4(v),_x2(v) #define _x31(v) _x30(v), v -#endif // GX2_SHADER_INL_H +#endif /* GX2_SHADER_INL_H */ diff --git a/wiiu/hbl.c b/wiiu/hbl.c index 6d4c438e95..c1918d7ff7 100644 --- a/wiiu/hbl.c +++ b/wiiu/hbl.c @@ -50,27 +50,27 @@ typedef struct _memory_values_t static const memory_values_t mem_vals_540[] = { - { 0x2E609EFC, 0x2FF82000 }, // 26083 kB - { 0x29030800, 0x293F6000 }, // 3864 kB - { 0x288EEC30, 0x28B06800 }, // 2144 kB - { 0x2D3B966C, 0x2D894000 }, // 4971 kB - { 0x2CB56370, 0x2D1EF000 }, // 6756 kB - { 0x2D8AD3D8, 0x2E000000 }, // 7499 kB - { 0x2970200C, 0x298B9800 }, // 1759 kB - { 0x2A057B68, 0x2A1B9000 }, // 1414 kB - { 0x2ABBCC4C, 0x2ACB9000 }, // 1010 kB + { 0x2E609EFC, 0x2FF82000 }, /* 26083 kB */ + { 0x29030800, 0x293F6000 }, /* 3864 kB */ + { 0x288EEC30, 0x28B06800 }, /* 2144 kB */ + { 0x2D3B966C, 0x2D894000 }, /* 4971 kB */ + { 0x2CB56370, 0x2D1EF000 }, /* 6756 kB */ + { 0x2D8AD3D8, 0x2E000000 }, /* 7499 kB */ + { 0x2970200C, 0x298B9800 }, /* 1759 kB */ + { 0x2A057B68, 0x2A1B9000 }, /* 1414 kB */ + { 0x2ABBCC4C, 0x2ACB9000 }, /* 1010 kB */ {0, 0} }; static inline void memoryAddArea(int start, int end, int cur_index) { - // Create and copy new memory area + /* Create and copy new memory area */ s_mem_area * mem_area = MEM_AREA_TABLE; mem_area[cur_index].address = start; mem_area[cur_index].size = end - start; mem_area[cur_index].next = 0; - // Fill pointer to this area in the previous area + /* Fill pointer to this area in the previous area */ if (cur_index > 0) { mem_area[cur_index - 1].next = &mem_area[cur_index]; @@ -89,13 +89,13 @@ static void memoryInitAreaTable(u32 args_size) { u32 ApplicationMemoryEnd = (u32)getApplicationEndAddr() + args_size; - // This one seems to be available on every firmware and therefore its our code area but also our main RPX area behind our code - // 22876 kB - our application // ok + /* This one seems to be available on every firmware and therefore its our code area but also our main RPX area behind our code */ + /* 22876 kB - our application ok */ memoryAddArea(ApplicationMemoryEnd + 0x30000000, 0x30000000 + 0x01E20000, 0); const memory_values_t * mem_vals = mem_vals_540; - // Fill entries + /* Fill entries */ int i = 0; while (mem_vals[i].start_address) { @@ -116,10 +116,10 @@ static int HomebrewCopyMemory(u8 *address, u32 bytes, u32 args_size) RPX_MAX_SIZE = 0x40000000; RPX_MAX_CODE_SIZE = 0x03000000; - // check if we load an RPX or an ELF + /* check if we load an RPX or an ELF */ if (*(u16 *)&address[7] != 0xCAFE) { - // assume ELF + /* assume ELF */ printf("loading ELF file \n"); ELF_DATA_ADDR = (u32)getApplicationEndAddr() + args_size; @@ -128,13 +128,13 @@ static int HomebrewCopyMemory(u8 *address, u32 bytes, u32 args_size) } else { - // RPX + /* RPX */ printf("loading RPX file \n"); ELF_DATA_ADDR = MEM_AREA_TABLE->address; } - //! if we load an ELF file + /*! if we load an ELF file */ if (ELF_DATA_ADDR < 0x01000000) { @@ -211,7 +211,7 @@ int HBL_loadToMemory(const char *filepath, u32 args_size) return -1; } - // Copy rpl in memory + /* Copy rpl in memory */ while (bytesRead < fileSize) { printf("progress: %f \r", 100.0f * (f32)bytesRead / (f32)fileSize); diff --git a/wiiu/hbl.h b/wiiu/hbl.h index 89cba6d735..f34f5451e9 100644 --- a/wiiu/hbl.h +++ b/wiiu/hbl.h @@ -22,4 +22,4 @@ void* getApplicationEndAddr(void); } #endif -#endif // __WIIU_HBL_LOADER_H__ +#endif /* __WIIU_HBL_LOADER_H__ */ diff --git a/wiiu/include/sys/socket.h b/wiiu/include/sys/socket.h index 4563a506e3..aa1c20f60c 100644 --- a/wiiu/include/sys/socket.h +++ b/wiiu/include/sys/socket.h @@ -18,13 +18,13 @@ extern "C" { #define SOCK_DGRAM 2 #define MSG_DONTWAIT 0x0020 -//#define MSG_DONTWAIT 0x0004 +/* #define MSG_DONTWAIT 0x0004 */ #define SO_REUSEADDR 0x0004 #define SO_NBIO 0x1014 -// return codes +/* return codes */ #define SO_SUCCESS 0 #define SO_EWOULDBLOCK 6 diff --git a/wiiu/include/wiiu/ax/device.h b/wiiu/include/wiiu/ax/device.h index d809245a79..71426bc033 100644 --- a/wiiu/include/wiiu/ax/device.h +++ b/wiiu/include/wiiu/ax/device.h @@ -11,7 +11,7 @@ typedef void(*AXAuxCallback)(void*, void*); enum AX_DEVICE_MODE { - // Unknown + /* Unknown */ AX_DEVICE_MODE_UNKNOWN }; typedef uint32_t AXDeviceMode; diff --git a/wiiu/include/wiiu/ax/drcvs.h b/wiiu/include/wiiu/ax/drcvs.h index 6190fb06a0..0399f8e5f5 100644 --- a/wiiu/include/wiiu/ax/drcvs.h +++ b/wiiu/include/wiiu/ax/drcvs.h @@ -8,31 +8,31 @@ extern "C" { typedef enum { - // Unknown + /* Unknown */ AX_DRC_VS_MODE_UNKNOWN } AXDRCVSMode; typedef enum { - // Unknown + /* Unknown */ AX_DRC_VS_OUTPUT_UNKNOWN } AXDRCVSOutput; typedef enum { - // Unknown + /* Unknown */ AX_DRC_VS_LC_UNKNOWN } AXDRCVSLC; typedef enum { - // Unknown + /* Unknown */ AX_DRC_VS_SPEAKER_POS_UNKNOWN } AXDRCVSSpeakerPosition; typedef enum AX_DRC_VS_SURROUND_GAIN { - // Unknown + /* Unknown */ AX_DRC_VS_SURROUND_GAIN_UNKNOWN } AXDRCVSSurroundLevelGain; diff --git a/wiiu/include/wiiu/ax/voice.h b/wiiu/include/wiiu/ax/voice.h index 0de23dab05..32092bf5c2 100644 --- a/wiiu/include/wiiu/ax/voice.h +++ b/wiiu/include/wiiu/ax/voice.h @@ -60,7 +60,7 @@ typedef uint32_t AXVoiceState; enum AX_VOICE_TYPE { - // Unknown + /* Unknown */ AX_VOICE_TYPE_UNKNOWN }; typedef uint32_t AXVoiceType; diff --git a/wiiu/include/wiiu/mem/memheap.h b/wiiu/include/wiiu/mem/memheap.h index 876a2ccd98..0a7c661eb0 100644 --- a/wiiu/include/wiiu/mem/memheap.h +++ b/wiiu/include/wiiu/mem/memheap.h @@ -32,25 +32,25 @@ typedef enum MEMHeapFlags typedef struct MEMHeapHeader { - //! Tag indicating which type of heap this is + /*! Tag indicating which type of heap this is */ MEMHeapTag tag; - //! Link for list this heap is in + /*! Link for list this heap is in */ MEMMemoryLink link; - //! List of all child heaps in this heap + /*! List of all child heaps in this heap */ MEMMemoryList list; - //! Pointer to start of allocatable memory + /*! Pointer to start of allocatable memory */ void *dataStart; - //! Pointer to end of allocatable memory + /*! Pointer to end of allocatable memory */ void *dataEnd; - //! Lock used when MEM_HEAP_FLAG_USE_LOCK is set. + /*! Lock used when MEM_HEAP_FLAG_USE_LOCK is set. */ OSSpinLock lock; - //! Flags set during heap creation. + /*! Flags set during heap creation. */ uint32_t flags; uint32_t __unknown[0x3]; diff --git a/wiiu/include/wiiu/nsyskbd.h b/wiiu/include/wiiu/nsyskbd.h index 5e2fceb1b1..d4785778fa 100644 --- a/wiiu/include/wiiu/nsyskbd.h +++ b/wiiu/include/wiiu/nsyskbd.h @@ -26,10 +26,10 @@ typedef enum _KBDModifier typedef struct _KBDKeyEvent { unsigned char channel; - unsigned char scancode; // scancode - KEYState state; // when held, value is 0x03, which is KBD_DOWN & KBD_REPEAT - KBDModifier modifier; // modifier state - unsigned short UTF16; // unicode, if any + unsigned char scancode; /* scancode */ + KEYState state; /* when held, value is 0x03, which is KBD_DOWN & KBD_REPEAT */ + KBDModifier modifier; /* modifier state */ + unsigned short UTF16; /* unicode, if any */ } KBDKeyEvent; char KBDSetup(void *connection_callback, void *disconnection_callback, void *key_callback); diff --git a/wiiu/include/wiiu/os/thread.h b/wiiu/include/wiiu/os/thread.h index ab29aff4bd..a21eef07aa 100644 --- a/wiiu/include/wiiu/os/thread.h +++ b/wiiu/include/wiiu/os/thread.h @@ -16,16 +16,16 @@ enum OS_THREAD_STATE { OS_THREAD_STATE_NONE = 0, - //! Thread is ready to run + /*! Thread is ready to run */ OS_THREAD_STATE_READY = 1 << 0, - //! Thread is running + /*! Thread is running */ OS_THREAD_STATE_RUNNING = 1 << 1, - //! Thread is waiting, i.e. on a mutex + /*! Thread is waiting, i.e. on a mutex */ OS_THREAD_STATE_WAITING = 1 << 2, - //! Thread is about to terminate + /*! Thread is about to terminate */ OS_THREAD_STATE_MORIBUND = 1 << 3, }; typedef uint8_t OSThreadState; @@ -40,22 +40,22 @@ typedef uint32_t OSThreadRequest; enum OS_THREAD_ATTRIB { - //! Allow the thread to run on CPU0. + /*! Allow the thread to run on CPU0. */ OS_THREAD_ATTRIB_AFFINITY_CPU0 = 1 << 0, - //! Allow the thread to run on CPU1. + /*! Allow the thread to run on CPU1. */ OS_THREAD_ATTRIB_AFFINITY_CPU1 = 1 << 1, - //! Allow the thread to run on CPU2. + /*! Allow the thread to run on CPU2. */ OS_THREAD_ATTRIB_AFFINITY_CPU2 = 1 << 2, - //! Allow the thread to run any CPU. + /*! Allow the thread to run any CPU. */ OS_THREAD_ATTRIB_AFFINITY_ANY = ((1 << 0) | (1 << 1) | (1 << 2)), - //! Start the thread detached. + /*! Start the thread detached. */ OS_THREAD_ATTRIB_DETACHED = 1 << 3, - //! Enables tracking of stack usage. + /*! Enables tracking of stack usage. */ OS_THREAD_ATTRIB_STACK_USAGE = 1 << 5 }; typedef uint8_t OSThreadAttributes; @@ -64,7 +64,7 @@ typedef uint8_t OSThreadAttributes; typedef struct OSContext { - //! Should always be set to the value OS_CONTEXT_TAG. + /*! Should always be set to the value OS_CONTEXT_TAG. */ uint64_t tag; uint32_t gpr[32]; @@ -138,93 +138,93 @@ typedef struct OSThread { OSContext context; - //! Should always be set to the value OS_THREAD_TAG. + /*! Should always be set to the value OS_THREAD_TAG. */ uint32_t tag; - //! Bitfield of OS_THREAD_STATE + /*! Bitfield of OS_THREAD_STATE */ OSThreadState state; - //! Bitfield of OS_THREAD_ATTRIB + /*! Bitfield of OS_THREAD_ATTRIB */ OSThreadAttributes attr; - //! Unique thread ID + /*! Unique thread ID */ uint16_t id; - //! Suspend count (increased by OSSuspendThread). + /*! Suspend count (increased by OSSuspendThread). */ int32_t suspendCounter; - //! Actual priority of thread. + /*! Actual priority of thread. */ int32_t priority; - //! Base priority of thread, 0 is highest priority, 31 is lowest priority. + /*! Base priority of thread, 0 is highest priority, 31 is lowest priority. */ int32_t basePriority; - //! Exit value + /*! Exit value */ int32_t exitValue; uint32_t unknown0[0x9]; - //! Queue the thread is currently waiting on + /*! Queue the thread is currently waiting on */ OSThreadQueue *queue; - //! Link used for thread queue + /*! Link used for thread queue */ OSThreadLink link; - //! Queue of threads waiting to join this thread + /*! Queue of threads waiting to join this thread */ OSThreadQueue joinQueue; - //! Mutex this thread is waiting to lock + /*! Mutex this thread is waiting to lock */ OSMutex *mutex; - //! Queue of mutexes this thread owns + /*! Queue of mutexes this thread owns */ OSMutexQueue mutexQueue; - //! Link for global active thread queue + /*! Link for global active thread queue */ OSThreadLink activeLink; - //! Stack start (top, highest address) + /*! Stack start (top, highest address) */ void *stackStart; - //! Stack end (bottom, lowest address) + /*! Stack end (bottom, lowest address) */ void *stackEnd; - //! Thread entry point + /*! Thread entry point */ OSThreadEntryPointFn entryPoint; uint32_t unknown1[0x77]; - //! Thread specific values, accessed with OSSetThreadSpecific and OSGetThreadSpecific. + /*! Thread specific values, accessed with OSSetThreadSpecific and OSGetThreadSpecific. */ uint32_t specific[0x10]; uint32_t unknown2; - //! Thread name, accessed with OSSetThreadName and OSGetThreadName. + /*! Thread name, accessed with OSSetThreadName and OSGetThreadName. */ const char *name; uint32_t unknown3; - //! The stack pointer passed in OSCreateThread. + /*! The stack pointer passed in OSCreateThread. */ void *userStackPointer; - //! Called just before thread is terminated, set with OSSetThreadCleanupCallback + /*! Called just before thread is terminated, set with OSSetThreadCleanupCallback */ OSThreadCleanupCallbackFn cleanupCallback; - //! Called just after a thread is terminated, set with OSSetThreadDeallocator + /*! Called just after a thread is terminated, set with OSSetThreadDeallocator */ OSThreadDeallocatorFn deallocator; - //! If TRUE then a thread can be cancelled or suspended, set with OSSetThreadCancelState + /*! If TRUE then a thread can be cancelled or suspended, set with OSSetThreadCancelState */ BOOL cancelState; - //! Current thread request, used for cancelleing and suspending the thread. + /*! Current thread request, used for cancelleing and suspending the thread. */ OSThreadRequest requestFlag; - //! Pending suspend request count + /*! Pending suspend request count */ int32_t needSuspend; - //! Result of thread suspend + /*! Result of thread suspend */ int32_t suspendResult; - //! Queue of threads waiting for a thread to be suspended. + /*! Queue of threads waiting for a thread to be suspended. */ OSThreadQueue suspendQueue; uint32_t unknown4[0x2B]; diff --git a/wiiu/include/wiiu/os/time.h b/wiiu/include/wiiu/os/time.h index 01c8b89b71..79349b0d7b 100644 --- a/wiiu/include/wiiu/os/time.h +++ b/wiiu/include/wiiu/os/time.h @@ -10,9 +10,9 @@ extern "C" { #define OSMicroseconds(val) ((((uint64_t)(val)) * (uint64_t)(OSOneSecond)) / 1000000ull) #define OSNanoseconds(val) ((((uint64_t)(val)) * (uint64_t)(OSOneSecond)) / 1000000000ull) -#define wiiu_bus_clock (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2*2*2) // 248.625000 Mhz -#define wiiu_cpu_clock (17 * 13 * 5*5*5 * 5*5*5 * 5 * 3*3 * 2*2*2) // 1243.125000 Mhz -#define wiiu_timer_clock (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2) // 62.156250 Mhz +#define wiiu_bus_clock (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2*2*2) /* 248.625000 Mhz */ +#define wiiu_cpu_clock (17 * 13 * 5*5*5 * 5*5*5 * 5 * 3*3 * 2*2*2) /* 1243.125000 Mhz */ +#define wiiu_timer_clock (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2) /* 62.156250 Mhz */ #define sec_to_ticks(s) (((17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2) * (uint64_t)(s))) #define ms_to_ticks(ms) (((17 * 13 * 5*5*5 * 3*3) * (uint64_t)(ms)) / (2*2)) diff --git a/wiiu/include/wiiu/pad_driver.h b/wiiu/include/wiiu/pad_driver.h index 02e9db5d6d..376b899f43 100644 --- a/wiiu/include/wiiu/pad_driver.h +++ b/wiiu/include/wiiu/pad_driver.h @@ -19,7 +19,7 @@ #ifdef HAVE_CONFIG_H #include "../../config.h" -#endif // HAVE_CONFIG_H +#endif /* HAVE_CONFIG_H */ #include #include @@ -63,15 +63,15 @@ * These are used by the wiimote driver to identify the wiimote configuration * attached to the channel. */ -// wiimote with Wii U Pro controller +/* wiimote with Wii U Pro controller */ #define WIIMOTE_TYPE_PRO 0x1f -// wiimote with Classic Controller +/* wiimote with Classic Controller */ #define WIIMOTE_TYPE_CLASSIC 0x02 -// wiimote with nunchuk +/* wiimote with nunchuk */ #define WIIMOTE_TYPE_NUNCHUK 0x01 -// wiimote plus (no accessory attached) +/* wiimote plus (no accessory attached) */ #define WIIMOTE_TYPE_WIIPLUS 0x00 -// wiimote not attached on this channel +/* wiimote not attached on this channel */ #define WIIMOTE_TYPE_NONE 0xFD /** @@ -116,17 +116,17 @@ struct _wiiu_pad_functions { */ typedef struct wiiu_hid { - // used to register for HID notifications + /* used to register for HID notifications */ HIDClient *client; - // list of HID pads + /* list of HID pads */ joypad_connection_t *connections; - // size of connections list + /* size of connections list */ unsigned connections_size; - // thread state data for HID polling thread + /* thread state data for HID polling thread */ OSThread *polling_thread; - // stack space for polling thread + /* stack space for polling thread */ void *polling_thread_stack; - // watch variable to tell the polling thread to terminate + /* watch variable to tell the polling thread to terminate */ volatile bool polling_thread_quit; } wiiu_hid_t; @@ -180,4 +180,4 @@ extern input_device_driver_t kpad_driver; extern input_device_driver_t hidpad_driver; extern hid_driver_t wiiu_hid; -#endif // __PAD_DRIVER__H +#endif /* __PAD_DRIVER__H */ diff --git a/wiiu/include/wiiu/syshid.h b/wiiu/include/wiiu/syshid.h index a940225dfa..1f55718dd9 100644 --- a/wiiu/include/wiiu/syshid.h +++ b/wiiu/include/wiiu/syshid.h @@ -5,10 +5,10 @@ * Report types for the report_type parameter in HIDSetReport() */ -// what is 1? +/* what is 1? */ #define HID_REPORT_OUTPUT 2 #define HID_REPORT_FEATURE 3 -// are there more? +/* are there more? */ typedef struct { diff --git a/wiiu/include/wiiu/vpad.h b/wiiu/include/wiiu/vpad.h index 3bf579915b..2c6765cbc3 100644 --- a/wiiu/include/wiiu/vpad.h +++ b/wiiu/include/wiiu/vpad.h @@ -86,13 +86,13 @@ typedef enum VPADButtons typedef enum VPADTouchPadValidity { - //! Both X and Y touchpad positions are accurate + /*! Both X and Y touchpad positions are accurate */ VPAD_VALID = 0x0, - //! X position is inaccurate + /*! X position is inaccurate */ VPAD_INVALID_X = 0x1, - //! Y position is inaccurate + /*! Y position is inaccurate */ VPAD_INVALID_Y = 0x2, } VPADTouchPadValidity; @@ -158,13 +158,13 @@ typedef struct VPADStatus uint16_t __unknown0; - //! Current touch position on DRC + /*! Current touch position on DRC */ VPADTouchData tpNormal; - //! Filtered touch position, first level of smoothing + /*! Filtered touch position, first level of smoothing */ VPADTouchData tpFiltered1; - //! Filtered touch position, second level of smoothing + /*! Filtered touch position, second level of smoothing */ VPADTouchData tpFiltered2; uint32_t __unknown1[0xA]; @@ -177,7 +177,7 @@ typedef struct VPADStatus uint32_t __unknown2[0x2]; }VPADStatus; -//! Deprecated +/*! Deprecated */ void VPADInit(); int32_t VPADRead(uint32_t chan, VPADStatus *buffers, uint32_t count, VPADReadError *error); diff --git a/wiiu/input/wiiu_hid.h b/wiiu/input/wiiu_hid.h index 68d66e156e..1c2ede6f73 100644 --- a/wiiu/input/wiiu_hid.h +++ b/wiiu/input/wiiu_hid.h @@ -53,4 +53,4 @@ static void wiiu_hid_read_loop_callback(uint32_t handle, int32_t error, uint8_t *buffer, uint32_t buffer_size, void *userdata); static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack); -#endif // __WIIU_HID__H +#endif /* __WIIU_HID__H */ diff --git a/wiiu/shader_utils.h b/wiiu/shader_utils.h index 4ff1b2c100..e03b3af704 100644 --- a/wiiu/shader_utils.h +++ b/wiiu/shader_utils.h @@ -3,7 +3,7 @@ #include /* incompatible with elf builds */ -//#define GX2_CAN_ACCESS_DATA_SECTION +/* #define GX2_CAN_ACCESS_DATA_SECTION */ #ifdef __cplusplus extern "C" { diff --git a/wiiu/sprite_shader.c b/wiiu/sprite_shader.c index b300b62e70..b34c48d222 100644 --- a/wiiu/sprite_shader.c +++ b/wiiu/sprite_shader.c @@ -35,30 +35,30 @@ static struct END_OF_PROGRAM }, { - ALU_MOV_x2(_R127,_x, _R3,_y), //@64 + ALU_MOV_x2(_R127,_x, _R3,_y), /* @64 */ ALU_MOV_x2(__,_y, _R3,_x), ALU_MOV_x2(_R127,_z, _R3,_w), - ALU_MOV_x2(__,_w, _R3,_z), //@70 + ALU_MOV_x2(__,_w, _R3,_z), /* @70 */ ALU_RECIP_IEEE(__,__, KC0(0), _x) SCL_210 ALU_LAST, ALU_MUL_IEEE(_R0,_z, ALU_SRC_PV, _w, ALU_SRC_PS, _x), ALU_MUL_IEEE(__,_w, ALU_SRC_PV,_y, ALU_SRC_PS,_x), ALU_RECIP_IEEE(__,_z, KC0(0),_y) SCL_210 ALU_LAST, - ALU_ADD(_R0,_x, ALU_SRC_PV,_w, ALU_SRC_1 _NEG,_x), //@80 + ALU_ADD(_R0,_x, ALU_SRC_PV,_w, ALU_SRC_1 _NEG,_x), /* @80 */ ALU_MUL_IEEE(__,_z, _R127,_x, ALU_SRC_PS,_x), ALU_MUL_IEEE(_R0,_w, _R127,_z, ALU_SRC_PS,_x), ALU_RECIP_IEEE(__,__, KC1(0),_x) SCL_210 ALU_LAST, ALU_MUL_IEEE(_R3,_x, _R2,_x, ALU_SRC_PS,_x), - ALU_ADD(_R0,_y, ALU_SRC_PV _NEG,_z, ALU_SRC_1,_x), //@90 + ALU_ADD(_R0,_y, ALU_SRC_PV _NEG,_z, ALU_SRC_1,_x), /* @90 */ ALU_MUL_IEEE(_R3,_z, _R2,_z, ALU_SRC_PS,_x), ALU_RECIP_IEEE(__,__, KC1(0),_y) SCL_210 ALU_LAST, ALU_MUL_IEEE(_R3,_y, _R2,_y, ALU_SRC_PS,_x), ALU_MUL_IEEE(_R3,_w, _R2,_w, ALU_SRC_PS,_x) ALU_LAST, - ALU_MOV(_R1,_x, _R1,_x), //@100 + ALU_MOV(_R1,_x, _R1,_x), /* @100 */ ALU_MOV(_R1,_y, _R1,_y), ALU_MOV(_R1,_z, _R1,_z), ALU_MOV(_R1,_w, _R1,_w) @@ -74,9 +74,9 @@ static struct __attribute__((aligned(GX2_SHADER_ALIGNMENT))) static struct { - u64 cf[32]; // @0 - u64 alu[16]; // @32 - u64 tex[1 * 2]; // @48 + u64 cf[32]; /* @0 */ + u64 alu[16]; /* @32 */ + u64 tex[1 * 2]; /* @48 */ } ps_program = { { @@ -100,9 +100,9 @@ static struct __attribute__((aligned(GX2_SHADER_ALIGNMENT))) static struct { - u64 cf[32]; // @0 - u64 alu[80-32]; // @32 - u64 tex[3 * 2]; // @80 + u64 cf[32]; /* @0 */ + u64 alu[80-32]; /* @32 */ + u64 tex[3 * 2]; /* @80 */ } gs_program = { { @@ -169,7 +169,7 @@ static struct ALU_LAST, }, { - VTX_FETCH(_R7,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(16), OFFSET(0)), // @160 + VTX_FETCH(_R7,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(16), OFFSET(0)), /* @160 */ VTX_FETCH(_R1,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(16), OFFSET(32)), VTX_FETCH(_R0,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(16), OFFSET(16)), } @@ -178,8 +178,8 @@ static struct __attribute__((aligned(GX2_SHADER_ALIGNMENT))) static struct { - u64 cf[16]; // @0 - u64 vtx[3 * 2]; // @16 + u64 cf[16]; /* @0 */ + u64 vtx[3 * 2]; /* @16 */ } gs_copy_program= { { diff --git a/wiiu/sprite_shader.h b/wiiu/sprite_shader.h index c0a92ed875..dfbf4a6f56 100644 --- a/wiiu/sprite_shader.h +++ b/wiiu/sprite_shader.h @@ -49,4 +49,4 @@ extern GX2Shader sprite_shader; } #endif -#endif // SPRITE_SHADER_H +#endif /* SPRITE_SHADER_H */ diff --git a/wiiu/system/dynamic.c b/wiiu/system/dynamic.c index cb8a9f7cbd..4bc859ef46 100644 --- a/wiiu/system/dynamic.c +++ b/wiiu/system/dynamic.c @@ -12,7 +12,7 @@ #define IMPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while(0) #define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle) -//#define IMPORT_END() OSDynLoad_Release(handle) +/* #define IMPORT_END() OSDynLoad_Release(handle) */ #define IMPORT_END() void InitFunctionPointers(void) diff --git a/wiiu/system/dynamic.h b/wiiu/system/dynamic.h index 9f02a0d809..51792185bd 100644 --- a/wiiu/system/dynamic.h +++ b/wiiu/system/dynamic.h @@ -3,4 +3,4 @@ void InitFunctionPointers(void); -#endif // DYNAMIC_H +#endif /* DYNAMIC_H */ diff --git a/wiiu/system/exception_handler.c b/wiiu/system/exception_handler.c index 4b8fb7bb30..bfba8dfd45 100644 --- a/wiiu/system/exception_handler.c +++ b/wiiu/system/exception_handler.c @@ -13,7 +13,7 @@ * If not, see . */ -//TODO: Program exceptions don't seem to work. Good thing they almost never happen. +/* TODO: Program exceptions don't seem to work. Good thing they almost never happen. */ #include #include diff --git a/wiiu/system/missing_libc_functions.c b/wiiu/system/missing_libc_functions.c index f192aeead0..2ebd6f9fda 100644 --- a/wiiu/system/missing_libc_functions.c +++ b/wiiu/system/missing_libc_functions.c @@ -8,21 +8,21 @@ #include #include -//This is usually in libogc; we can't use that on wiiu +/* This is usually in libogc; we can't use that on wiiu */ int usleep(useconds_t microseconds) { OSSleepTicks(us_to_ticks(microseconds)); return 0; } -//Can't find this one anywhere for some reason :/ -//This could probably be done a lot better with some love +/* Can't find this one anywhere for some reason :/ */ +/* This could probably be done a lot better with some love */ int access(const char* path, int mode) { - return 0; //TODO temp hack, real code below + return 0; /* TODO temp hack, real code below */ FILE* fd = fopen(path, "rb"); if (fd < 0) { fclose(fd); - //We're supposed to set errono here + /* We're supposed to set errono here */ return -1; } else { fclose(fd); @@ -30,14 +30,14 @@ int access(const char* path, int mode) { } } -//Just hardcode the Linux User ID, we're not on linux anyway -//Feasible cool addition: nn::act for this? +/* Just hardcode the Linux User ID, we're not on linux anyway */ +/* Feasible cool addition: nn::act for this? */ uid_t getuid() { return 1000; } -//Fake user info -//Not thread safe, but avoids returning local variable, so... +/* Fake user info */ +/* Not thread safe, but avoids returning local variable, so... */ struct passwd out; struct passwd* getpwuid(uid_t uid) { out.pw_name = "retroarch"; @@ -51,9 +51,9 @@ struct passwd* getpwuid(uid_t uid) { return &out; } -//Try to vaugely spoof the POISX clock. Epoch is off by about 30 -//years, so this could be better... -//Only has second accuracy since I'm lazy. +/* Try to vaugely spoof the POISX clock. Epoch is off by about 30 */ +/* years, so this could be better... */ +/* Only has second accuracy since I'm lazy. */ int clock_gettime(clockid_t clk_id, struct timespec* tp) { int64_t time_usec = cpu_features_get_time_usec(); tp->tv_sec = time_usec / 1000000; diff --git a/wiiu/tex_shader.h b/wiiu/tex_shader.h index d9a80292af..b7271eace8 100644 --- a/wiiu/tex_shader.h +++ b/wiiu/tex_shader.h @@ -43,4 +43,4 @@ extern GX2Shader tex_shader; } #endif -#endif // TEX_SHADER_H +#endif /* TEX_SHADER_H */ diff --git a/wiiu/wiiu_dbg.h b/wiiu/wiiu_dbg.h index bbfc99ec65..b75edfaf27 100644 --- a/wiiu/wiiu_dbg.h +++ b/wiiu/wiiu_dbg.h @@ -12,8 +12,8 @@ extern "C" { #endif -//void wait_for_input(void); -//void dump_result_value(Result val); +/* void wait_for_input(void); */ +/* void dump_result_value(Result val); */ void* OSGetSymbolName(u32 addr, char* out, u32 out_size); void DisassemblePPCRange(void *start, void *end, void* printf_func, void* GetSymbolName_func, u32 flags); @@ -24,7 +24,7 @@ void DisassemblePPCRange(void *start, void *end, void* printf_func, void* GetSym #define DEBUG_DISASM(start, count) DisassemblePPCRange((void*)start, (u32*)(start) + (count), printf, OSGetSymbolName, 0) #endif /* WIIU */ -//#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) +/* #define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) */ #define DEBUG_LINE() do{printf("%s:%4d %s().\n", __FILE__, __LINE__, __FUNCTION__);fflush(stdout);}while(0) #define DEBUG_STR(X) printf( "%s: %s\n", #X, (char*)(X)) #define DEBUG_VAR(X) printf( "%-20s: 0x%08" PRIX32 "\n", #X, (uint32_t)(X)) @@ -34,9 +34,9 @@ void DisassemblePPCRange(void *start, void *end, void* printf_func, void* GetSym #define DEBUG_VAR64(X) printf( #X"\r\t\t\t\t : 0x%016" PRIX64 "\n", (uint64_t)(X)) #define DEBUG_MAGIC(X) printf( "%-20s: '%c''%c''%c''%c' (0x%08X)\n", #X, (u32)(X)>>24, (u32)(X)>>16, (u32)(X)>>8, (u32)(X),(u32)(X)) -//#define DEBUG_ERROR(X) do{if(X)dump_result_value(X);}while(0) +/* #define DEBUG_ERROR(X) do{if(X)dump_result_value(X);}while(0) */ #define PRINTFPOS(X,Y) "\x1b["#X";"#Y"H" #define PRINTFPOS_STR(X,Y) "\x1b[" X ";" Y "H" #define PRINTF_LINE(X) "\x1b[" X ";0H" -#endif // WIIU_DBG_H +#endif /* WIIU_DBG_H */ diff --git a/wiiu/wut/elf2rpl/elf.h b/wiiu/wut/elf2rpl/elf.h index 17a77b70e3..a476bba825 100644 --- a/wiiu/wut/elf2rpl/elf.h +++ b/wiiu/wut/elf2rpl/elf.h @@ -7,49 +7,49 @@ namespace elf { -enum Machine : uint32_t // e_machine +enum Machine : uint32_t /* e_machine */ { - EM_PPC = 20 // PowerPC + EM_PPC = 20 /* PowerPC */ }; -enum Encoding : uint32_t // e_encoding +enum Encoding : uint32_t /* e_encoding */ { ELFDATANONE = 0, ELFDATA2LSB = 1, ELFDATA2MSB = 2 }; -enum Class : uint32_t // e_class +enum Class : uint32_t /* e_class */ { ELFCLASSNONE = 0, ELFCLASS32 = 1, ELFCLASS64 = 2 }; -enum Version : uint32_t // e_elf_version +enum Version : uint32_t /* e_elf_version */ { EV_NONE = 0, EV_CURRENT = 1, }; -enum FileType : uint32_t // e_type +enum FileType : uint32_t /* e_type */ { - ET_NONE = 0, // No file type - ET_REL = 1, // Relocatable file - ET_EXEC = 2, // Executable file - ET_DYN = 3, // Shared object file - ET_CORE = 4, // Core file - ET_LOPROC = 0xff00, // Beginning of processor-specific codes - ET_CAFE_RPL = 0xff01, // Cafe RPL file - ET_HIPROC = 0xffff // Processor-specific + ET_NONE = 0, /* No file type */ + ET_REL = 1, /* Relocatable file */ + ET_EXEC = 2, /* Executable file */ + ET_DYN = 3, /* Shared object file */ + ET_CORE = 4, /* Core file */ + ET_LOPROC = 0xff00, /* Beginning of processor-specific codes */ + ET_CAFE_RPL = 0xff01, /* Cafe RPL file */ + ET_HIPROC = 0xffff /* Processor-specific */ }; -enum EABI : uint32_t // e_abi +enum EABI : uint32_t /* e_abi */ { - EABI_CAFE = 0xcafe // WiiU CafeOS + EABI_CAFE = 0xcafe /* WiiU CafeOS */ }; -enum SectionFlags : uint32_t // sh_flags +enum SectionFlags : uint32_t /* sh_flags */ { SHF_WRITE = 0x1, SHF_ALLOC = 0x2, @@ -58,74 +58,74 @@ enum SectionFlags : uint32_t // sh_flags SHF_MASKPROC = 0xF0000000, }; -enum SectionType : uint32_t // sh_type +enum SectionType : uint32_t /* sh_type */ { - SHT_NULL = 0, // No associated section (inactive entry). - SHT_PROGBITS = 1, // Program-defined contents. - SHT_SYMTAB = 2, // Symbol table. - SHT_STRTAB = 3, // String table. - SHT_RELA = 4, // Relocation entries; explicit addends. - SHT_HASH = 5, // Symbol hash table. - SHT_DYNAMIC = 6, // Information for dynamic linking. - SHT_NOTE = 7, // Information about the file. - SHT_NOBITS = 8, // Data occupies no space in the file. - SHT_REL = 9, // Relocation entries; no explicit addends. - SHT_SHLIB = 10, // Reserved. - SHT_DYNSYM = 11, // Symbol table. - SHT_INIT_ARRAY = 14, // Pointers to initialization functions. - SHT_FINI_ARRAY = 15, // Pointers to termination functions. - SHT_PREINIT_ARRAY = 16, // Pointers to pre-init functions. - SHT_GROUP = 17, // Section group. - SHT_SYMTAB_SHNDX = 18, // Indices for SHN_XINDEX entries. - SHT_LOPROC = 0x70000000, // Lowest processor arch-specific type. - SHT_HIPROC = 0x7fffffff, // Highest processor arch-specific type. - SHT_LOUSER = 0x80000000, // Lowest type reserved for applications. - SHT_RPL_EXPORTS = 0x80000001, // RPL Exports - SHT_RPL_IMPORTS = 0x80000002, // RPL Imports - SHT_RPL_CRCS = 0x80000003, // RPL CRCs - SHT_RPL_FILEINFO = 0x80000004,// RPL FileInfo - SHT_HIUSER = 0xffffffff // Highest type reserved for applications. + SHT_NULL = 0, /* No associated section (inactive entry). */ + SHT_PROGBITS = 1, /* Program-defined contents. */ + SHT_SYMTAB = 2, /* Symbol table. */ + SHT_STRTAB = 3, /* String table. */ + SHT_RELA = 4, /* Relocation entries; explicit addends. */ + SHT_HASH = 5, /* Symbol hash table. */ + SHT_DYNAMIC = 6, /* Information for dynamic linking. */ + SHT_NOTE = 7, /* Information about the file. */ + SHT_NOBITS = 8, /* Data occupies no space in the file. */ + SHT_REL = 9, /* Relocation entries; no explicit addends. */ + SHT_SHLIB = 10, /* Reserved. */ + SHT_DYNSYM = 11, /* Symbol table. */ + SHT_INIT_ARRAY = 14, /* Pointers to initialization functions. */ + SHT_FINI_ARRAY = 15, /* Pointers to termination functions. */ + SHT_PREINIT_ARRAY = 16, /* Pointers to pre-init functions. */ + SHT_GROUP = 17, /* Section group. */ + SHT_SYMTAB_SHNDX = 18, /* Indices for SHN_XINDEX entries. */ + SHT_LOPROC = 0x70000000, /* Lowest processor arch-specific type. */ + SHT_HIPROC = 0x7fffffff, /* Highest processor arch-specific type. */ + SHT_LOUSER = 0x80000000, /* Lowest type reserved for applications. */ + SHT_RPL_EXPORTS = 0x80000001, /* RPL Exports */ + SHT_RPL_IMPORTS = 0x80000002, /* RPL Imports */ + SHT_RPL_CRCS = 0x80000003, /* RPL CRCs */ + SHT_RPL_FILEINFO = 0x80000004,/* RPL FileInfo */ + SHT_HIUSER = 0xffffffff /* Highest type reserved for applications. */ }; -enum SymbolBinding : uint32_t // st_info >> 4 +enum SymbolBinding : uint32_t /* st_info >> 4 */ { - STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def - STB_GLOBAL = 1, // Global symbol, visible to all object files being combined - STB_WEAK = 2, // Weak symbol, like global but lower-precedence + STB_LOCAL = 0, /* Local symbol, not visible outside obj file containing def */ + STB_GLOBAL = 1, /* Global symbol, visible to all object files being combined */ + STB_WEAK = 2, /* Weak symbol, like global but lower-precedence */ STB_GNU_UNIQUE = 10, - STB_LOOS = 10, // Lowest operating system-specific binding type - STB_HIOS = 12, // Highest operating system-specific binding type - STB_LOPROC = 13, // Lowest processor-specific binding type - STB_HIPROC = 15 // Highest processor-specific binding type + STB_LOOS = 10, /* Lowest operating system-specific binding type */ + STB_HIOS = 12, /* Highest operating system-specific binding type */ + STB_LOPROC = 13, /* Lowest processor-specific binding type */ + STB_HIPROC = 15 /* Highest processor-specific binding type */ }; -enum SymbolType : uint32_t // st_info & f +enum SymbolType : uint32_t /* st_info & f */ { - STT_NOTYPE = 0, // Symbol's type is not specified - STT_OBJECT = 1, // Symbol is a data object (variable, array, etc.) - STT_FUNC = 2, // Symbol is executable code (function, etc.) - STT_SECTION = 3, // Symbol refers to a section - STT_FILE = 4, // Local, absolute symbol that refers to a file - STT_COMMON = 5, // An uninitialized common block - STT_TLS = 6, // Thread local data object - STT_LOOS = 7, // Lowest operating system-specific symbol type - STT_HIOS = 8, // Highest operating system-specific symbol type - STT_GNU_IFUNC = 10, // GNU indirect function - STT_LOPROC = 13, // Lowest processor-specific symbol type - STT_HIPROC = 15 // Highest processor-specific symbol type + STT_NOTYPE = 0, /* Symbol's type is not specified */ + STT_OBJECT = 1, /* Symbol is a data object (variable, array, etc.) */ + STT_FUNC = 2, /* Symbol is executable code (function, etc.) */ + STT_SECTION = 3, /* Symbol refers to a section */ + STT_FILE = 4, /* Local, absolute symbol that refers to a file */ + STT_COMMON = 5, /* An uninitialized common block */ + STT_TLS = 6, /* Thread local data object */ + STT_LOOS = 7, /* Lowest operating system-specific symbol type */ + STT_HIOS = 8, /* Highest operating system-specific symbol type */ + STT_GNU_IFUNC = 10, /* GNU indirect function */ + STT_LOPROC = 13, /* Lowest processor-specific symbol type */ + STT_HIPROC = 15 /* Highest processor-specific symbol type */ }; -enum SectionIndex : uint16_t // st_shndx +enum SectionIndex : uint16_t /* st_shndx */ { - SHN_UNDEF = 0, // Undefined - SHN_LORESERVE = 0xff00, // Reserved range - SHN_ABS = 0xfff1, // Absolute symbols - SHN_COMMON = 0xfff2, // Common symbols - SHN_XINDEX = 0xffff, // Escape -- index stored elsewhere + SHN_UNDEF = 0, /* Undefined */ + SHN_LORESERVE = 0xff00, /* Reserved range */ + SHN_ABS = 0xfff1, /* Absolute symbols */ + SHN_COMMON = 0xfff2, /* Common symbols */ + SHN_XINDEX = 0xffff, /* Escape -- index stored elsewhere */ SHN_HIRESERVE = 0xffff }; -enum RelocationType : uint32_t // r_info & 0xff +enum RelocationType : uint32_t /* r_info & 0xff */ { R_PPC_NONE = 0, R_PPC_ADDR32 = 1, @@ -196,52 +196,52 @@ static const unsigned HeaderMagic = 0x7f454c46; struct Header { - be_val magic; // File identification. - be_val fileClass; // File class. - be_val encoding; // Data encoding. - be_val elfVersion; // File version. - be_val abi; // OS/ABI identification. (EABI_*) + be_val magic; /* File identification. */ + be_val fileClass; /* File class. */ + be_val encoding; /* Data encoding. */ + be_val elfVersion; /* File version. */ + be_val abi; /* OS/ABI identification. (EABI_*) */ be_val pad[7]; - be_val type; // Type of file (ET_*) - be_val machine; // Required architecture for this file (EM_*) - be_val version; // Must be equal to 1 - be_val entry; // Address to jump to in order to start program - be_val phoff; // Program header table's file offset, in bytes - be_val shoff; // Section header table's file offset, in bytes - be_val flags; // Processor-specific flags - be_val ehsize; // Size of ELF header, in bytes - be_val phentsize; // Size of an entry in the program header table - be_val phnum; // Number of entries in the program header table - be_val shentsize; // Size of an entry in the section header table - be_val shnum; // Number of entries in the section header table - be_val shstrndx; // Sect hdr table index of sect name string table + be_val type; /* Type of file (ET_*) */ + be_val machine; /* Required architecture for this file (EM_*) */ + be_val version; /* Must be equal to 1 */ + be_val entry; /* Address to jump to in order to start program */ + be_val phoff; /* Program header table's file offset, in bytes */ + be_val shoff; /* Section header table's file offset, in bytes */ + be_val flags; /* Processor-specific flags */ + be_val ehsize; /* Size of ELF header, in bytes */ + be_val phentsize; /* Size of an entry in the program header table */ + be_val phnum; /* Number of entries in the program header table */ + be_val shentsize; /* Size of an entry in the section header table */ + be_val shnum; /* Number of entries in the section header table */ + be_val shstrndx; /* Sect hdr table index of sect name string table */ }; CHECK_SIZE(Header, 0x34); struct SectionHeader { - be_val name; // Section name (index into string table) - be_val type; // Section type (SHT_*) - be_val flags; // Section flags (SHF_*) - be_val addr; // Address where section is to be loaded - be_val offset; // File offset of section data, in bytes - be_val size; // Size of section, in bytes - be_val link; // Section type-specific header table index link - be_val info; // Section type-specific extra information - be_val addralign; // Section address alignment - be_val entsize; // Size of records contained within the section + be_val name; /* Section name (index into string table) */ + be_val type; /* Section type (SHT_*) */ + be_val flags; /* Section flags (SHF_*) */ + be_val addr; /* Address where section is to be loaded */ + be_val offset; /* File offset of section data, in bytes */ + be_val size; /* Size of section, in bytes */ + be_val link; /* Section type-specific header table index link */ + be_val info; /* Section type-specific extra information */ + be_val addralign; /* Section address alignment */ + be_val entsize; /* Size of records contained within the section */ }; CHECK_SIZE(SectionHeader, 0x28); struct Symbol { - be_val name; // Symbol name (index into string table) - be_val value; // Value or address associated with the symbol - be_val size; // Size of the symbol - be_val info; // Symbol's type and binding attributes - be_val other; // Must be zero; reserved - be_val shndx; // Which section (header table index) it's defined in (SHN_*) + be_val name; /* Symbol name (index into string table) */ + be_val value; /* Value or address associated with the symbol */ + be_val size; /* Size of the symbol */ + be_val info; /* Symbol's type and binding attributes */ + be_val other; /* Must be zero; reserved */ + be_val shndx; /* Which section (header table index) it's defined in (SHN_*) */ }; CHECK_SIZE(Symbol, 0x10); @@ -309,6 +309,6 @@ struct RplFileInfo }; CHECK_SIZE(RplFileInfo, 0x60); -} // namespace elf +} /* namespace elf */ #pragma pack(pop) diff --git a/wiiu/wut/elf2rpl/main.cpp b/wiiu/wut/elf2rpl/main.cpp index 4a035984cf..63011567e0 100644 --- a/wiiu/wut/elf2rpl/main.cpp +++ b/wiiu/wut/elf2rpl/main.cpp @@ -52,10 +52,10 @@ struct ElfFile elf::SectionType type; elf::SectionFlags flags; - // Data used if type == SHT_PROGBITS + /* Data used if type == SHT_PROGBITS */ std::vector data; - // Size used if type == SHT_NOBITS + /* Size used if type == SHT_NOBITS */ uint32_t size; }; @@ -153,7 +153,7 @@ read(ElfFile &file, const std::string &filename) return false; } - // Read header + /* Read header */ elf::Header header; in.read(reinterpret_cast(&header), sizeof(elf::Header)); @@ -184,7 +184,7 @@ read(ElfFile &file, const std::string &filename) file.entryPoint = header.entry; - // Read section headers and data + /* Read section headers and data */ in.seekg(static_cast(header.shoff)); inSections.resize(header.shnum); @@ -204,7 +204,7 @@ read(ElfFile &file, const std::string &filename) auto shStrTab = inSections[header.shstrndx].data.data(); - // Process any loader relocations + /* Process any loader relocations */ for (auto §ion : inSections) { if (section.header.type != elf::SHT_RELA) { continue; @@ -239,7 +239,7 @@ read(ElfFile &file, const std::string &filename) *ptr = byte_swap(addr); break; case elf::R_PPC_NONE: - // ignore padding + /* ignore padding */ break; default: std::cout << "Unexpected relocation type in .rela.dyn section" << std::endl; @@ -248,10 +248,10 @@ read(ElfFile &file, const std::string &filename) } } - // Read text/data sections + /* Read text/data sections */ for (auto §ion : inSections) { if (section.header.addr >= LoadAddress && section.header.addr < CodeAddress) { - // Skip any load sections + /* Skip any load sections */ continue; } @@ -276,7 +276,7 @@ read(ElfFile &file, const std::string &filename) } } - // Default symbols + /* Default symbols */ auto symNull = new ElfFile::Symbol(); symNull->address = 0; symNull->size = 0; @@ -308,7 +308,7 @@ read(ElfFile &file, const std::string &filename) symUndef->binding = elf::STB_GLOBAL; file.symbols.emplace_back(symUndef); - // Read symbols + /* Read symbols */ for (auto §ion : inSections) { if (section.header.type != elf::SHT_SYMTAB) { continue; @@ -329,7 +329,7 @@ read(ElfFile &file, const std::string &filename) auto &sym = symTab[i]; if (sym.value >= LoadAddress && sym.value < CodeAddress) { - // Skip any load symbols + /* Skip any load symbols */ continue; } @@ -337,12 +337,12 @@ read(ElfFile &file, const std::string &filename) auto binding = static_cast((sym.info >> 4) & 0xF); if (type == elf::STT_NOTYPE && sym.value == 0) { - // Skip null symbol + /* Skip null symbol */ continue; } if (type == elf::STT_FILE || type == elf::STT_SECTION) { - // Skip file, section symbols + /* Skip file, section symbols */ continue; } @@ -356,7 +356,7 @@ read(ElfFile &file, const std::string &filename) } } - // Read RPL imports + /* Read RPL imports */ for (auto §ion : inSections) { auto name = std::string { shStrTab + section.header.name }; @@ -377,10 +377,10 @@ read(ElfFile &file, const std::string &filename) import->trampAddr = byte_swap(*getLoaderDataPtr(inSections, stubAddr)); import->stubAddr = stubAddr; - // Get the tramp symbol + /* Get the tramp symbol */ import->trampSymbol = findSymbol(file, import->trampAddr); - // Create a new symbol to use for the import + /* Create a new symbol to use for the import */ auto stubSymbol = new ElfFile::Symbol(); import->stubSymbol = stubSymbol; stubSymbol->name = import->trampSymbol->name; @@ -390,7 +390,7 @@ read(ElfFile &file, const std::string &filename) stubSymbol->type = elf::STT_FUNC; file.symbols.emplace_back(stubSymbol); - // Rename tramp symbol + /* Rename tramp symbol */ import->trampSymbol->name += "_tramp"; lib->imports.emplace_back(import); @@ -400,7 +400,7 @@ read(ElfFile &file, const std::string &filename) } } - // Read relocations + /* Read relocations */ for (auto §ion : inSections) { if (section.header.type != elf::SHT_RELA) { continue; @@ -409,7 +409,7 @@ read(ElfFile &file, const std::string &filename) auto name = std::string { shStrTab + section.header.name }; if (name.compare(".rela.dyn") == 0) { - // Skip dyn relocations + /* Skip dyn relocations */ continue; } @@ -448,7 +448,7 @@ read(ElfFile &file, const std::string &filename) relocation->symbol = findSymbol(file, CodeAddress); relocation->addend = addend - CodeAddress; } else { - // If we can't find a proper symbol, write the addend in and hope for the best + /* If we can't find a proper symbol, write the addend in and hope for the best */ auto ptr = getLoaderDataPtr(inSections, rela.offset); *ptr = addend; @@ -462,7 +462,7 @@ read(ElfFile &file, const std::string &filename) } } - // Read dyn relocations + /* Read dyn relocations */ for (auto §ion : inSections) { if (section.header.type != elf::SHT_RELA) { continue; @@ -489,7 +489,7 @@ read(ElfFile &file, const std::string &filename) if(type == elf::R_PPC_NONE) { - // ignore padding + /* ignore padding */ continue; } @@ -529,7 +529,7 @@ read(ElfFile &file, const std::string &filename) relocation->target = rela.offset; relocation->type = static_cast(type); - // Scrap any compiler/linker garbage + /* Scrap any compiler/linker garbage */ if(relocation->target >= CodeAddress && relocation->target < WiiuLoadAddress) file.relocations.emplace_back(relocation); } @@ -597,12 +597,12 @@ write(ElfFile &file, const std::string &filename) std::vector outSections; auto sectionSymbolItr = file.symbols.begin() + 4; - // Create NULL section + /* Create NULL section */ auto nullSection = new OutputSection(); memset(&nullSection->header, 0, sizeof(elf::SectionHeader)); outSections.push_back(nullSection); - // Create text/data sections + /* Create text/data sections */ for (auto §ion : file.dataSections) { auto out = new OutputSection(); out->header.name = -1; @@ -622,20 +622,20 @@ write(ElfFile &file, const std::string &filename) if (section->address == DataAddress) { out->header.addralign = 4096; - out->header.flags |= elf::SHF_WRITE; // .rodata needs to be writable? + out->header.flags |= elf::SHF_WRITE; /* .rodata needs to be writable? */ } else { out->header.addralign = 256; } out->header.entsize = 0; - // Add section + /* Add section */ out->name = section->name; out->data = section->data; sectionSymbolItr = addSection(file, outSections, sectionSymbolItr, out); } - // Create relocation sections + /* Create relocation sections */ for (auto &relocation : file.relocations) { OutputSection *targetSection = nullptr; @@ -655,7 +655,7 @@ write(ElfFile &file, const std::string &filename) } if (!targetSection->relocationSection) { - // Create new relocation section + /* Create new relocation section */ auto out = new OutputSection(); out->header.name = -1; out->header.type = elf::SHT_RELA; @@ -668,14 +668,14 @@ write(ElfFile &file, const std::string &filename) out->header.addralign = 4; out->header.entsize = sizeof(elf::Rela); - // Add section + /* Add section */ out->name = ".rela" + targetSection->name; sectionSymbolItr = addSection(file, outSections, sectionSymbolItr, out); targetSection->relocationSection = out; } } - // Calculate sizes of symbol/string tables so RPL imports are placed after them + /* Calculate sizes of symbol/string tables so RPL imports are placed after them */ auto loadAddress = 0xC0000000; auto predictStrTabSize = 1; auto predictSymTabSize = 1; @@ -695,7 +695,7 @@ write(ElfFile &file, const std::string &filename) predictShstrTabSize = align_up(predictShstrTabSize, 0x10); loadAddress += predictStrTabSize + predictSymTabSize + predictShstrTabSize; - // Create RPL import sections, .fimport_*, .dimport_* + /* Create RPL import sections, .fimport_*, .dimport_* */ for (auto &lib : file.rplImports) { auto out = new OutputSection(); out->header.name = -1; @@ -709,31 +709,31 @@ write(ElfFile &file, const std::string &filename) out->header.entsize = 0; out->name = ".fimport_" + lib->name; - // Calculate size + /* Calculate size */ auto nameSize = align_up(8 + lib->name.size(), 8); auto stubSize = 8 + 8 * lib->imports.size(); out->header.size = std::max(nameSize, stubSize); out->data.resize(out->header.size); - // Setup data + /* Setup data */ auto imports = reinterpret_cast(out->data.data()); imports->count = lib->imports.size(); imports->signature = crc32(0, Z_NULL, 0); memcpy(imports->name, lib->name.data(), lib->name.size()); imports->name[lib->name.size()] = 0; - // Update address of import symbols + /* Update address of import symbols */ for (auto i = 0u; i < lib->imports.size(); ++i) { lib->imports[i]->stubSymbol->address = loadAddress + 8 + i * 8; } loadAddress = align_up(loadAddress + out->header.size, 4); - // Add section + /* Add section */ sectionSymbolItr = addSection(file, outSections, sectionSymbolItr, out); } - // Prune out unneeded symbols + /* Prune out unneeded symbols */ for (auto i = 0u; i < file.symbols.size(); ++i) { if (!file.symbols[i]->name.empty() && file.symbols[i]->type == elf::STT_NOTYPE && file.symbols[i]->size == 0) { file.symbols.erase(file.symbols.begin() + i); @@ -741,9 +741,9 @@ write(ElfFile &file, const std::string &filename) } } - // NOTICE: FROM NOW ON DO NOT MODIFY mSymbols + /* NOTICE: FROM NOW ON DO NOT MODIFY mSymbols */ - // Convert relocations + /* Convert relocations */ for (auto &relocation : file.relocations) { OutputSection *targetSection = nullptr; @@ -762,17 +762,17 @@ write(ElfFile &file, const std::string &filename) return false; } - // Get address of relocation->target + /* Get address of relocation->target */ auto relocationSection = targetSection->relocationSection; - // Find symbol this relocation points to + /* Find symbol this relocation points to */ auto itr = std::find_if(file.symbols.begin(), file.symbols.end(), [&relocation](auto &val) { return val.get() == relocation->symbol; }); auto idx = itr - file.symbols.begin(); - // If the symbol doesn't exist but it is within DATA or TEXT, use those symbols + an addend + /* If the symbol doesn't exist but it is within DATA or TEXT, use those symbols + an addend */ if (itr == file.symbols.end()) { if (relocation->symbol->address >= CodeAddress && relocation->symbol->address < DataAddress) { idx = 1; @@ -788,7 +788,7 @@ write(ElfFile &file, const std::string &filename) } } - // Create relocation + /* Create relocation */ elf::Rela rela; rela.info = relocation->type | idx << 8; @@ -799,12 +799,12 @@ write(ElfFile &file, const std::string &filename) rela.addend = relocation->addend; rela.offset = relocation->target; - // Append to relocation section data + /* Append to relocation section data */ char *relaData = reinterpret_cast(&rela); relocationSection->data.insert(relocationSection->data.end(), relaData, relaData + sizeof(elf::Rela)); } - // String + Symbol sections + /* String + Symbol sections */ auto symTabSection = new OutputSection(); auto strTabSection = new OutputSection(); auto shStrTabSection = new OutputSection(); @@ -822,7 +822,7 @@ write(ElfFile &file, const std::string &filename) auto shStrTabIndex = outSections.size(); outSections.push_back(shStrTabSection); - // Update relocation sections to link to symtab + /* Update relocation sections to link to symtab */ for (auto §ion : outSections) { if (section->header.type == elf::SHT_RELA) { section->header.link = symTabIndex; @@ -838,7 +838,7 @@ write(ElfFile &file, const std::string &filename) } } - // Create .strtab + /* Create .strtab */ strTabSection->header.name = 0; strTabSection->header.type = elf::SHT_STRTAB; strTabSection->header.flags = elf::SHF_ALLOC; @@ -850,7 +850,7 @@ write(ElfFile &file, const std::string &filename) strTabSection->header.addralign = 1; strTabSection->header.entsize = 0; - // Add all symbol names to data, update symbol->outNamePos + /* Add all symbol names to data, update symbol->outNamePos */ strTabSection->data.push_back(0); for (auto &symbol : file.symbols) { @@ -863,7 +863,7 @@ write(ElfFile &file, const std::string &filename) } } - // Create .symtab + /* Create .symtab */ symTabSection->header.name = 0; symTabSection->header.type = elf::SHT_SYMTAB; symTabSection->header.flags = elf::SHF_ALLOC; @@ -895,19 +895,19 @@ write(ElfFile &file, const std::string &filename) sym.other = 0; sym.shndx = shndx; - //Compound symbol crc into section crc + /* Compound symbol crc into section crc */ auto crcSection = outSections[shndx]; if(crcSection->header.type == elf::SHT_RPL_IMPORTS && symbol->type != elf::STT_SECTION) { auto rplImport = reinterpret_cast(crcSection->data.data()); rplImport->signature = crc32(rplImport->signature, reinterpret_cast(strTabSection->data.data() + sym.name),strlen(strTabSection->data.data() + sym.name)+1); } - // Append to symtab data + /* Append to symtab data */ char *symData = reinterpret_cast(&sym); symTabSection->data.insert(symTabSection->data.end(), symData, symData + sizeof(elf::Symbol)); } - //Finish SHT_RPL_IMPORTS signatures + /* Finish SHT_RPL_IMPORTS signatures */ Bytef *zero_buffer = reinterpret_cast(calloc(0x10, 1)); for (auto §ion : outSections) { if(section->header.type == elf::SHT_RPL_IMPORTS) { @@ -917,7 +917,7 @@ write(ElfFile &file, const std::string &filename) } free(zero_buffer); - // Create .shstrtab + /* Create .shstrtab */ shStrTabSection->header.name = 0; shStrTabSection->header.type = elf::SHT_STRTAB; shStrTabSection->header.flags = elf::SHF_ALLOC; @@ -929,7 +929,7 @@ write(ElfFile &file, const std::string &filename) shStrTabSection->header.addralign = 1; shStrTabSection->header.entsize = 0; - // Add all section header names to data, update section->header.name + /* Add all section header names to data, update section->header.name */ shStrTabSection->data.push_back(0); for (auto §ion : outSections) { @@ -944,7 +944,7 @@ write(ElfFile &file, const std::string &filename) loadAddress = 0xC0000000; - // Update symtab, strtab, shstrtab section addresses + /* Update symtab, strtab, shstrtab section addresses */ symTabSection->header.addr = loadAddress; symTabSection->header.size = symTabSection->data.size(); @@ -956,7 +956,7 @@ write(ElfFile &file, const std::string &filename) shStrTabSection->header.addr = loadAddress; shStrTabSection->header.size = shStrTabSection->data.size(); - // Create SHT_RPL_FILEINFO section + /* Create SHT_RPL_FILEINFO section */ auto fileInfoSection = new OutputSection(); fileInfoSection->header.name = 0; fileInfoSection->header.type = elf::SHT_RPL_FILEINFO; @@ -996,7 +996,7 @@ write(ElfFile &file, const std::string &filename) fileInfo.runtimeFileInfoSize = 0; fileInfo.tagOffset = 0; - // Count file info textSize, dataSize, loadSize + /* Count file info textSize, dataSize, loadSize */ for (auto §ion : outSections) { auto size = section->data.size(); @@ -1024,14 +1024,14 @@ write(ElfFile &file, const std::string &filename) } } - //TODO: These were calculated based on observation, however some games differ. + /* TODO: These were calculated based on observation, however some games differ. */ fileInfo.sdaBase = align_up(DataAddress + fileInfo.dataSize + fileInfo.heapSize, 64); fileInfo.sda2Base = align_up(DataAddress + fileInfo.heapSize, 64); char *fileInfoData = reinterpret_cast(&fileInfo); fileInfoSection->data.insert(fileInfoSection->data.end(), fileInfoData, fileInfoData + sizeof(elf::RplFileInfo)); - // Create SHT_RPL_CRCS section + /* Create SHT_RPL_CRCS section */ auto crcSection = new OutputSection(); crcSection->header.name = 0; crcSection->header.type = elf::SHT_RPL_CRCS; @@ -1063,11 +1063,11 @@ write(ElfFile &file, const std::string &filename) char *crcData = reinterpret_cast(sectionCRCs.data()); crcSection->data.insert(crcSection->data.end(), crcData, crcData + sizeof(uint32_t) * sectionCRCs.size()); - // Update section sizes and offsets + /* Update section sizes and offsets */ auto shoff = align_up(sizeof(elf::Header), 64); auto dataOffset = align_up(shoff + outSections.size() * sizeof(elf::SectionHeader), 64); - // Add CRC and FileInfo sections first + /* Add CRC and FileInfo sections first */ for (auto §ion : outSections) { if (section->header.type != elf::SHT_RPL_CRCS && section->header.type != elf::SHT_RPL_FILEINFO) { continue; @@ -1085,7 +1085,7 @@ write(ElfFile &file, const std::string &filename) } } - // Add data sections next + /* Add data sections next */ for (auto §ion : outSections) { if(section->header.offset != -1) { continue; @@ -1107,7 +1107,7 @@ write(ElfFile &file, const std::string &filename) } } - // Add load sections next + /* Add load sections next */ for (auto §ion : outSections) { if(section->header.offset != -1) { continue; @@ -1129,7 +1129,7 @@ write(ElfFile &file, const std::string &filename) } } - // Everything else + /* Everything else */ for (auto §ion : outSections) { if(section->header.offset != -1) { continue; @@ -1147,7 +1147,7 @@ write(ElfFile &file, const std::string &filename) } } - // Write to file + /* Write to file */ std::ofstream out { filename, std::ofstream::binary }; std::vector padding; @@ -1178,14 +1178,14 @@ write(ElfFile &file, const std::string &filename) header.shstrndx = shStrTabIndex; out.write(reinterpret_cast(&header), sizeof(elf::Header)); - // Write section headers + /* Write section headers */ out.seekp(header.shoff.value()); for (auto §ion : outSections) { out.write(reinterpret_cast(§ion->header), sizeof(elf::SectionHeader)); } - // Write section data + /* Write section data */ for (auto §ion : outSections) { if (!section->data.empty()) { out.seekp(section->header.offset.value()); diff --git a/wiiu/wut/elf2rpl/utils.h b/wiiu/wut/elf2rpl/utils.h index 817dff3427..5df4e14b85 100644 --- a/wiiu/wut/elf2rpl/utils.h +++ b/wiiu/wut/elf2rpl/utils.h @@ -16,7 +16,7 @@ #include #endif -// reinterpret_cast for value types +/* reinterpret_cast for value types */ template inline DstType bit_cast(const SrcType& src) @@ -30,8 +30,8 @@ bit_cast(const SrcType& src) return dst; } -// Utility class to swap endian for types of size 1, 2, 4, 8 -// other type sizes are not supported +/* Utility class to swap endian for types of size 1, 2, 4, 8 */ +/* other type sizes are not supported */ template struct byte_swap_t; @@ -52,7 +52,7 @@ struct byte_swap_t #ifdef PLATFORM_WINDOWS return bit_cast(_byteswap_ushort(bit_cast(src))); #elif defined(PLATFORM_APPLE) - // Apple has no 16-bit byteswap intrinsic + /* Apple has no 16-bit byteswap intrinsic */ const uint16_t data = bit_cast(src); return bit_cast((uint16_t)((data >> 8) | (data << 8))); #elif defined(PLATFORM_LINUX) @@ -91,7 +91,7 @@ struct byte_swap_t } }; -// Swaps endian of src +/* Swaps endian of src */ template inline Type byte_swap(Type src) @@ -99,7 +99,7 @@ byte_swap(Type src) return byte_swap_t::swap(src); } -// Alignment helpers +/* Alignment helpers */ template constexpr inline Type align_up(Type value, size_t alignment)