1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-18 01:46:47 +00:00

all: Make file-scope variables internally linked where applicable (#57)

Narrows the scope of visible symbols to where they're actually used. Also
makes it easier to see true globals in source files
(ones used from multiple translation units)
This commit is contained in:
Mat M 2018-02-26 03:42:21 -05:00 committed by SciresM
parent c94cfe4898
commit 1de6b336bb
8 changed files with 17 additions and 18 deletions

View file

@ -8,7 +8,7 @@
#include "fuse.h" #include "fuse.h"
#include "utils.h" #include "utils.h"
int g_battery_profile = 0; static int g_battery_profile = 0;
uint32_t configitem_set(enum ConfigItem item, uint64_t value) { uint32_t configitem_set(enum ConfigItem item, uint64_t value) {
if (item != CONFIGITEM_BATTERYPROFILE) { if (item != CONFIGITEM_BATTERYPROFILE) {

View file

@ -4,7 +4,7 @@
#include "timers.h" #include "timers.h"
#include "utils.h" #include "utils.h"
saved_cpu_context_t g_cpu_contexts[NUM_CPU_CORES] = {0}; static saved_cpu_context_t g_cpu_contexts[NUM_CPU_CORES] = {0};
void set_core_entrypoint_and_context_id(uint32_t core, uint64_t entrypoint_addr, uint64_t context_id) { void set_core_entrypoint_and_context_id(uint32_t core, uint64_t entrypoint_addr, uint64_t context_id) {
g_cpu_contexts[core].ELR_EL3 = entrypoint_addr; g_cpu_contexts[core].ELR_EL3 = entrypoint_addr;

View file

@ -5,7 +5,7 @@
#include "interrupt.h" #include "interrupt.h"
/* Global of registered handlers. */ /* Global of registered handlers. */
struct { static struct {
unsigned int id; unsigned int id;
void (*handler)(void); void (*handler)(void);
} g_registered_interrupts[MAX_REGISTERED_INTERRUPTS] = { {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL} }; } g_registered_interrupts[MAX_REGISTERED_INTERRUPTS] = { {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL} };

View file

@ -5,15 +5,15 @@
#include "masterkey.h" #include "masterkey.h"
#include "se.h" #include "se.h"
unsigned int g_mkey_revision = 0; static unsigned int g_mkey_revision = 0;
bool g_determined_mkey_revision = false; static bool g_determined_mkey_revision = false;
uint8_t g_old_masterkeys[MASTERKEY_REVISION_MAX][0x10]; static uint8_t g_old_masterkeys[MASTERKEY_REVISION_MAX][0x10];
/* TODO: Dev keys. */ /* TODO: Dev keys. */
/* TODO: Extend with new vectors, as needed. */ /* TODO: Extend with new vectors, as needed. */
const uint8_t mkey_vectors[MASTERKEY_REVISION_MAX][0x10] = static const uint8_t mkey_vectors[MASTERKEY_REVISION_MAX][0x10] =
{ {
{0x0C, 0xF0, 0x59, 0xAC, 0x85, 0xF6, 0x26, 0x65, 0xE1, 0xE9, 0x19, 0x55, 0xE6, 0xF2, 0x67, 0x3D}, /* Zeroes encrypted with Master Key 00. */ {0x0C, 0xF0, 0x59, 0xAC, 0x85, 0xF6, 0x26, 0x65, 0xE1, 0xE9, 0x19, 0x55, 0xE6, 0xF2, 0x67, 0x3D}, /* Zeroes encrypted with Master Key 00. */
{0x29, 0x4C, 0x04, 0xC8, 0xEB, 0x10, 0xED, 0x9D, 0x51, 0x64, 0x97, 0xFB, 0xF3, 0x4D, 0x50, 0xDD}, /* Master key 00 encrypted with Master key 01. */ {0x29, 0x4C, 0x04, 0xC8, 0xEB, 0x10, 0xED, 0x9D, 0x51, 0x64, 0x97, 0xFB, 0xF3, 0x4D, 0x50, 0xDD}, /* Master key 00 encrypted with Master key 01. */

View file

@ -14,10 +14,10 @@ void trigger_se_rsa_op(void *buf, size_t size);
void trigger_se_blocking_op(unsigned int op, void *dst, size_t dst_size, const void *src, size_t src_size); void trigger_se_blocking_op(unsigned int op, void *dst, size_t dst_size, const void *src, size_t src_size);
/* Globals for driver. */ /* Globals for driver. */
unsigned int (*g_se_callback)(void); static unsigned int (*g_se_callback)(void);
unsigned int g_se_modulus_sizes[KEYSLOT_RSA_MAX]; static unsigned int g_se_modulus_sizes[KEYSLOT_RSA_MAX];
unsigned int g_se_exp_sizes[KEYSLOT_RSA_MAX]; static unsigned int g_se_exp_sizes[KEYSLOT_RSA_MAX];
/* Initialize a SE linked list. */ /* Initialize a SE linked list. */

View file

@ -4,12 +4,11 @@
#include "sealedkeys.h" #include "sealedkeys.h"
#include "se.h" #include "se.h"
const uint8_t g_titlekey_seal_key_source[0x10] = { static const uint8_t g_titlekey_seal_key_source[0x10] = {
0xCB, 0xB7, 0x6E, 0x38, 0xA1, 0xCB, 0x77, 0x0F, 0xB2, 0xA5, 0xB2, 0x9D, 0xD8, 0x56, 0x9F, 0x76 0xCB, 0xB7, 0x6E, 0x38, 0xA1, 0xCB, 0x77, 0x0F, 0xB2, 0xA5, 0xB2, 0x9D, 0xD8, 0x56, 0x9F, 0x76
}; };
static const uint8_t g_seal_key_sources[CRYPTOUSECASE_MAX][0x10] = {
const uint8_t g_seal_key_sources[CRYPTOUSECASE_MAX][0x10] = {
{0xF4, 0x0C, 0x16, 0x26, 0x0D, 0x46, 0x3B, 0xE0, 0x8C, 0x6A, 0x56, 0xE5, 0x82, 0xD4, 0x1B, 0xF6}, {0xF4, 0x0C, 0x16, 0x26, 0x0D, 0x46, 0x3B, 0xE0, 0x8C, 0x6A, 0x56, 0xE5, 0x82, 0xD4, 0x1B, 0xF6},
{0x7F, 0x54, 0x2C, 0x98, 0x1E, 0x54, 0x18, 0x3B, 0xBA, 0x63, 0xBD, 0x4C, 0x13, 0x5B, 0xF1, 0x06}, {0x7F, 0x54, 0x2C, 0x98, 0x1E, 0x54, 0x18, 0x3B, 0xBA, 0x63, 0xBD, 0x4C, 0x13, 0x5B, 0xF1, 0x06},
{0xC7, 0x3F, 0x73, 0x60, 0xB7, 0xB9, 0x9D, 0x74, 0x0A, 0xF8, 0x35, 0x60, 0x1A, 0x18, 0x74, 0x63}, {0xC7, 0x3F, 0x73, 0x60, 0xB7, 0xB9, 0x9D, 0x74, 0x0A, 0xF8, 0x35, 0x60, 0x1A, 0x18, 0x74, 0x63},

View file

@ -62,7 +62,7 @@ typedef struct {
uint32_t num_handlers; uint32_t num_handlers;
} smc_table_t; } smc_table_t;
smc_table_entry_t g_smc_user_table[SMC_USER_HANDLERS] = { static smc_table_entry_t g_smc_user_table[SMC_USER_HANDLERS] = {
{0, NULL}, {0, NULL},
{0xC3000401, smc_set_config}, {0xC3000401, smc_set_config},
{0xC3000002, smc_get_config}, {0xC3000002, smc_get_config},
@ -84,7 +84,7 @@ smc_table_entry_t g_smc_user_table[SMC_USER_HANDLERS] = {
{0xC3000012, smc_unwrap_aes_wrapped_titlekey} {0xC3000012, smc_unwrap_aes_wrapped_titlekey}
}; };
smc_table_entry_t g_smc_priv_table[SMC_PRIV_HANDLERS] = { static smc_table_entry_t g_smc_priv_table[SMC_PRIV_HANDLERS] = {
{0, NULL}, {0, NULL},
{0xC4000001, smc_cpu_suspend}, {0xC4000001, smc_cpu_suspend},
{0x84000002, smc_cpu_off}, {0x84000002, smc_cpu_off},
@ -96,7 +96,7 @@ smc_table_entry_t g_smc_priv_table[SMC_PRIV_HANDLERS] = {
{0xC3000008, smc_read_write_register} {0xC3000008, smc_read_write_register}
}; };
smc_table_t g_smc_tables[2] = { static smc_table_t g_smc_tables[2] = {
{ /* SMC_HANDLER_USER */ { /* SMC_HANDLER_USER */
g_smc_user_table, g_smc_user_table,
SMC_USER_HANDLERS SMC_USER_HANDLERS

View file

@ -8,8 +8,8 @@
#include "masterkey.h" #include "masterkey.h"
#include "se.h" #include "se.h"
uint64_t g_tkey_expected_label_hash[4]; static uint64_t g_tkey_expected_label_hash[4];
unsigned int g_tkey_master_key_rev = MASTERKEY_REVISION_MAX; static unsigned int g_tkey_master_key_rev = MASTERKEY_REVISION_MAX;
/* Set the expected db prefix. */ /* Set the expected db prefix. */
void tkey_set_expected_label_hash(uint64_t *label_hash) { void tkey_set_expected_label_hash(uint64_t *label_hash) {