diff --git a/fusee/fusee-secondary/linker.ld b/fusee/fusee-secondary/linker.ld index 0b68e76f0..39e5e6f96 100644 --- a/fusee/fusee-secondary/linker.ld +++ b/fusee/fusee-secondary/linker.ld @@ -14,15 +14,15 @@ PHDRS MEMORY { main : ORIGIN = 0xF0000000, LENGTH = 0x10000000 - high_iram : ORIGIN = 0x40010000, LENGTH = 0x20000 + high_iram : ORIGIN = 0x40010000, LENGTH = 0x8000 low_iram : ORIGIN = 0x40003000, LENGTH = 0x8000 } SECTIONS { PROVIDE(__start__ = 0xF0000000); - PROVIDE(__stack_top__ = 0x90020000); - PROVIDE(__stack_bottom__ = 0x90010000); + PROVIDE(__stack_top__ = 0x40020000); + PROVIDE(__stack_bottom__ = 0x40018000); PROVIDE(__heap_start__ = 0x90020000); PROVIDE(__heap_end__ = 0xA0020000); diff --git a/fusee/fusee-secondary/src/cluster.c b/fusee/fusee-secondary/src/cluster.c index df609d3db..5f2a242e7 100644 --- a/fusee/fusee-secondary/src/cluster.c +++ b/fusee/fusee-secondary/src/cluster.c @@ -82,19 +82,26 @@ static void cluster_enable_power(uint32_t regulator) { } } +static bool cluster_is_partition_powered(volatile tegra_pmc_t *pmc, uint32_t status) { + return (pmc->pwrgate_status & status) == status; +} + static void cluster_pmc_enable_partition(uint32_t part, uint32_t toggle) { volatile tegra_pmc_t *pmc = pmc_get_regs(); + const uint32_t status = (toggle << part); /* Check if the partition has already been turned on. */ - if (pmc->pwrgate_status & (toggle << part)) { + if (cluster_is_partition_powered(pmc, status)) { return; } - uint32_t i = 5001; - while (pmc->pwrgate_toggle & 0x100) { + int timeout = 5000; + while (true) { + if ((pmc->pwrgate_toggle & 0x100) == 0) { + break; + } udelay(1); - i--; - if (i < 1) { + if ((--timeout) < 0) { return; } } @@ -102,14 +109,15 @@ static void cluster_pmc_enable_partition(uint32_t part, uint32_t toggle) { /* Turn the partition on. */ pmc->pwrgate_toggle = (part | 0x100); - i = 5001; - while (i > 0) { - /* Check if the partition has already been turned on. */ - if (pmc->pwrgate_status & (toggle << part)) { + timeout = 5000; + while (true) { + if (cluster_is_partition_powered(pmc, status)) { break; } udelay(1); - i--; + if ((--timeout) < 0) { + return; + } } } diff --git a/fusee/fusee-secondary/src/init.c b/fusee/fusee-secondary/src/init.c index 7936626a4..a2c799890 100644 --- a/fusee/fusee-secondary/src/init.c +++ b/fusee/fusee-secondary/src/init.c @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #include #include #include diff --git a/fusee/fusee-secondary/src/nxboot_iram.c b/fusee/fusee-secondary/src/nxboot_iram.c index efed59c1c..51b7b07c6 100644 --- a/fusee/fusee-secondary/src/nxboot_iram.c +++ b/fusee/fusee-secondary/src/nxboot_iram.c @@ -35,14 +35,14 @@ static bool is_soc_mariko() { void nxboot_finish(uint32_t boot_memaddr) { bool is_mariko = is_soc_mariko(); - + /* Boot up Exosphère. */ MAILBOX_NX_BOOTLOADER_IS_SECMON_AWAKE = 0; MAILBOX_NX_BOOTLOADER_SETUP_STATE = NX_BOOTLOADER_STATE_DRAM_INITIALIZED_4X; /* Terminate the display. */ display_end(); - + if (is_mariko) { /* Boot CPU0. */ cluster_boot_cpu0(boot_memaddr);