mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
Sync sdmmc changes between stage1 and 2
This commit is contained in:
parent
2bc2fe1452
commit
2a98e2e3b8
4 changed files with 13 additions and 22 deletions
|
@ -28,7 +28,7 @@
|
||||||
#define CONSOLE_FG_COL 0xa0
|
#define CONSOLE_FG_COL 0xa0
|
||||||
|
|
||||||
/* Try using the small font */
|
/* Try using the small font */
|
||||||
//#define CONFIG_VIDEO_FONT_SMALL
|
#define CONFIG_VIDEO_FONT_SMALL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Graphic Data Format (GDF) bits for VIDEO_DATA_FORMAT
|
* Graphic Data Format (GDF) bits for VIDEO_DATA_FORMAT
|
||||||
|
|
|
@ -1278,7 +1278,7 @@ static int sdmmc_handle_cpu_transfer(struct mmc *mmc, uint16_t blocks, bool is_w
|
||||||
// Handle unaligned buffers
|
// Handle unaligned buffers
|
||||||
uint32_t w;
|
uint32_t w;
|
||||||
uint8_t *data = (uint8_t *)buffer;
|
uint8_t *data = (uint8_t *)buffer;
|
||||||
w = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
|
memcpy(&w, data, 4);
|
||||||
mmc->regs->buffer = w;
|
mmc->regs->buffer = w;
|
||||||
} else {
|
} else {
|
||||||
mmc->regs->buffer = *buffer;
|
mmc->regs->buffer = *buffer;
|
||||||
|
@ -1288,10 +1288,7 @@ static int sdmmc_handle_cpu_transfer(struct mmc *mmc, uint16_t blocks, bool is_w
|
||||||
// Handle unaligned buffers
|
// Handle unaligned buffers
|
||||||
uint32_t w = mmc->regs->buffer;
|
uint32_t w = mmc->regs->buffer;
|
||||||
uint8_t *data = (uint8_t *)buffer;
|
uint8_t *data = (uint8_t *)buffer;
|
||||||
data[0] = w & 0xFF;
|
memcpy(&w, data, 4);
|
||||||
data[1] = (w >> 8) & 0xFF;
|
|
||||||
data[2] = (w >> 16) & 0xFF;
|
|
||||||
data[3] = (w >> 24) & 0xFF;
|
|
||||||
} else {
|
} else {
|
||||||
*buffer = mmc->regs->buffer;
|
*buffer = mmc->regs->buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ void nxboot_main(void) {
|
||||||
generic_panic();
|
generic_panic();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef I_KNOW_WHAT_IM_DOING_2
|
#ifndef I_KNOW_WHAT_IM_DOING_2
|
||||||
pk2file = fopen("bcpkg21:/", "rb");
|
pk2file = fopen("bcpkg21:/", "rb");
|
||||||
if (pk2file == NULL || fseek(pk2file, 0x4000, SEEK_SET) != 0) {
|
if (pk2file == NULL || fseek(pk2file, 0x4000, SEEK_SET) != 0) {
|
||||||
printf("Error: Failed to open Package2 from NAND: %s!\n", strerror(errno));
|
printf("Error: Failed to open Package2 from NAND: %s!\n", strerror(errno));
|
||||||
|
@ -114,22 +114,12 @@ void nxboot_main(void) {
|
||||||
printf("Error: Package2 is too big or too small!\n");
|
printf("Error: Package2 is too big or too small!\n");
|
||||||
generic_panic();
|
generic_panic();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (fread(package2->data, package2_size - sizeof(package2_header_t), 1, pk2file) < 1) {
|
if (fread(package2->data, package2_size - sizeof(package2_header_t), 1, pk2file) < 1) {
|
||||||
printf("Error: Failed to read Package2!\n");
|
printf("Error: Failed to read Package2!\n");
|
||||||
generic_panic();
|
generic_panic();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
for (size_t i = 0; i < package2_size - sizeof(package2_header_t); i += 512*32) {
|
|
||||||
/* TODO: check if we have read everything, eventually. */
|
|
||||||
size_t r = fread(package2->data + i, 1, 512, pk2file);
|
|
||||||
if (r == 0) {
|
|
||||||
printf("Error: Failed to read Package2!\n");
|
|
||||||
generic_panic();
|
|
||||||
} else if (r < 512) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(pk2file);
|
fclose(pk2file);
|
||||||
printf("Read package2!\n");
|
printf("Read package2!\n");
|
||||||
|
|
||||||
|
|
|
@ -824,7 +824,7 @@ static int sdmmc1_switch_to_low_voltage(struct mmc *mmc)
|
||||||
*/
|
*/
|
||||||
static int sdmmc_always_fail(struct mmc *mmc)
|
static int sdmmc_always_fail(struct mmc *mmc)
|
||||||
{
|
{
|
||||||
// This card
|
// This card
|
||||||
return ENOSYS;
|
return ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,6 +1157,10 @@ static int sdmmc_wait_for_interrupt(struct mmc *mmc,
|
||||||
|
|
||||||
// Finally, EOI the relevant interrupt.
|
// Finally, EOI the relevant interrupt.
|
||||||
mmc->regs->int_status |= fault_conditions;
|
mmc->regs->int_status |= fault_conditions;
|
||||||
|
|
||||||
|
// Reset the timebase, so it applies to the next
|
||||||
|
// DMA interval.
|
||||||
|
timebase = get_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmc->regs->int_status & target_irq)
|
if (mmc->regs->int_status & target_irq)
|
||||||
|
@ -1637,7 +1641,7 @@ static int sdmmc_send_app_command(struct mmc *mmc, enum sdmmc_command command,
|
||||||
}
|
}
|
||||||
|
|
||||||
// And issue the body of the command.
|
// And issue the body of the command.
|
||||||
return sdmmc_send_command(mmc, command, response_type, checks, argument, response_buffer,
|
return sdmmc_send_command(mmc, command, response_type, checks, argument, response_buffer,
|
||||||
blocks_to_transfer, false, auto_terminate, data_buffer);
|
blocks_to_transfer, false, auto_terminate, data_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1959,7 +1963,7 @@ static int sdmmc_optimize_transfer_mode(struct mmc *mmc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: step up into high speed modes
|
// TODO: step up into high speed modes
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue