2018-04-19 13:24:26 +02:00
|
|
|
//---
|
|
|
|
// gint:core:bootlog - Boot-time on-screen log for extreme debugging
|
|
|
|
//---
|
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
#include <gint/defs/types.h>
|
2019-03-06 14:32:51 +01:00
|
|
|
#include <core/std.h>
|
|
|
|
#include <core/mmu.h>
|
|
|
|
|
2019-07-04 18:11:43 +02:00
|
|
|
#include <gint/hardware.h>
|
2019-02-21 20:58:38 +01:00
|
|
|
#include <gint/mpu/intc.h>
|
2019-03-06 14:32:51 +01:00
|
|
|
|
2018-04-19 13:24:26 +02:00
|
|
|
#include <gint/gint.h>
|
2019-02-22 15:08:51 +01:00
|
|
|
#include <gint/display.h>
|
2019-05-04 14:59:13 +02:00
|
|
|
#include <gint/syscalls.h>
|
2019-03-06 14:32:51 +01:00
|
|
|
#include <gint/clock.h>
|
2019-02-22 15:08:51 +01:00
|
|
|
|
2019-05-04 12:07:14 +02:00
|
|
|
#ifdef GINT_BOOT_LOG
|
|
|
|
|
2019-02-22 15:08:51 +01:00
|
|
|
#ifdef FXCG50
|
2019-03-06 14:32:51 +01:00
|
|
|
void Bdisp_AllClr_VRAM(void);
|
|
|
|
void Bdisp_PutDisp_DD(void);
|
2019-05-04 12:07:14 +02:00
|
|
|
void PrintXY(int x, int y, const char *str, int fg, int bg);
|
2019-02-22 15:08:51 +01:00
|
|
|
#define dclear(c) Bdisp_AllClr_VRAM()
|
|
|
|
#define dupdate() Bdisp_PutDisp_DD()
|
|
|
|
#endif
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-05-04 12:07:14 +02:00
|
|
|
/* A copy of the bootlog */
|
2019-07-04 18:13:31 +02:00
|
|
|
GDATA char gint_bootlog[22*8] = { 0 };
|
2019-05-04 12:07:14 +02:00
|
|
|
|
2018-04-19 13:24:26 +02:00
|
|
|
/* Linker script symbols - see core/start.c for details */
|
|
|
|
extern char
|
|
|
|
brom, srom,
|
|
|
|
sgdata, sgbss, sdata, sbss,
|
|
|
|
btors, mtors, etors;
|
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
/* print() - formatted printing shorthand */
|
|
|
|
static void print(int x, int y, const char *format, ...)
|
2018-04-19 13:24:26 +02:00
|
|
|
{
|
2019-03-06 14:32:51 +01:00
|
|
|
char str[45];
|
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
vsprintf(str + 2, format, args);
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
#ifdef FX9860G
|
2019-07-04 18:14:31 +02:00
|
|
|
dtext(6 * (x-1) + 1, 8 * (y-1), str + 2, C_BLACK, C_WHITE);
|
2019-03-06 14:32:51 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FXCG50
|
|
|
|
PrintXY(x, y, str, 0, 0);
|
|
|
|
#endif
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-07-04 18:13:31 +02:00
|
|
|
memcpy(gint_bootlog + 22 * (y-1) + (x-1), str + 2, strlen(str + 2));
|
2019-05-04 12:07:14 +02:00
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bootlog_loaded() - section loading stage */
|
|
|
|
GSECTION(".pretext")
|
|
|
|
void bootlog_loaded(void)
|
|
|
|
{
|
2019-07-04 18:13:31 +02:00
|
|
|
memset(gint_bootlog, 0x20, 22*8);
|
|
|
|
for(int i = 0; i < 8; i++) gint_bootlog[22 * i + 21] = 0;
|
|
|
|
|
2018-04-19 13:24:26 +02:00
|
|
|
/* Size of memory sections */
|
2019-03-06 14:32:51 +01:00
|
|
|
uint32_t rom_size = (uint32_t)&srom;
|
|
|
|
uint32_t ram_size = (uint32_t)&sdata + (uint32_t)&sbss;
|
|
|
|
uint32_t gint_size = (uint32_t)&sgdata + (uint32_t)&sgbss;
|
2018-04-19 13:24:26 +02:00
|
|
|
|
|
|
|
/* MPU type */
|
2019-07-04 18:11:43 +02:00
|
|
|
int mpu = gint[HWMPU];
|
2018-04-19 13:24:26 +02:00
|
|
|
const char *names = "SH7337\0 SH7305\0 SH7355\0 SH7724";
|
|
|
|
|
|
|
|
/* TODO: Use a solid API for boot-time printing */
|
2019-07-04 18:14:31 +02:00
|
|
|
dclear(C_WHITE);
|
2019-03-06 14:32:51 +01:00
|
|
|
print(1, 1, "gint @%7x SLmkd", GINT_VERSION);
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-07-04 18:11:43 +02:00
|
|
|
if(mpu >= 1 && mpu <= 4) print(1, 2, names + 8 * (mpu - 1));
|
2019-03-06 14:32:51 +01:00
|
|
|
else print(1, 2, "%6d", mpu);
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
#ifdef FX9860G
|
2019-07-04 18:11:43 +02:00
|
|
|
print(8, 2, "%c?-", gint[HWRAM] >= (512 << 10) ? 'R' : 'r');
|
2019-03-06 14:32:51 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FXCG50
|
2019-07-04 18:11:43 +02:00
|
|
|
print(8, 2, "---");
|
2019-03-06 14:32:51 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
char os[11];
|
|
|
|
__os_version(os);
|
|
|
|
print(12, 2, "OS%2s%2s%4s", os, os+3, os+6);
|
|
|
|
|
|
|
|
print(1, 3, "ROM%4dk RAM%3d+%1dk ??",
|
|
|
|
(rom_size + 0x3ff) >> 10,
|
|
|
|
(ram_size + 0x3ff) >> 10,
|
|
|
|
(gint_size + 0x3ff) >> 10);
|
2018-08-01 20:41:36 +02:00
|
|
|
|
2019-02-22 15:08:51 +01:00
|
|
|
dupdate();
|
2018-04-19 13:24:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bootlog_mapped() - ROM mapping stage */
|
2019-03-06 14:32:51 +01:00
|
|
|
GSECTION(".pretext")
|
2019-05-04 12:07:14 +02:00
|
|
|
void bootlog_mapped(int rom, GUNUSED int ram)
|
2018-04-19 13:24:26 +02:00
|
|
|
{
|
2019-03-06 14:32:51 +01:00
|
|
|
/* Check whether all ROM is mapped */
|
|
|
|
uint32_t rom_size = (uint32_t)&srom;
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
print(20, 3, "%c%c", (rom >= (int)rom_size) ? 'F' : 'f',
|
|
|
|
isSH3() ? 'u' : 'U');
|
|
|
|
print(19, 1, "M");
|
2019-03-10 15:45:34 +01:00
|
|
|
|
|
|
|
#ifdef FX9860G
|
|
|
|
print(9, 2, (ram > 8192) ? "E" : "e");
|
|
|
|
#endif
|
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
dupdate();
|
|
|
|
}
|
2018-08-01 20:41:36 +02:00
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
/* bootlog_unmapped() - ROM mapping stage failure */
|
|
|
|
void bootlog_unmapped(int rom, int size)
|
|
|
|
{
|
|
|
|
print(1, 6, "MMU: add-in too large");
|
|
|
|
print(1, 7, "%8x < %8x", rom, size);
|
2019-02-22 15:08:51 +01:00
|
|
|
dupdate();
|
2018-04-19 13:24:26 +02:00
|
|
|
}
|
|
|
|
|
2018-08-01 20:41:36 +02:00
|
|
|
/* bootlog_kernel() - gint loading stage */
|
2018-04-19 13:24:26 +02:00
|
|
|
void bootlog_kernel(void)
|
|
|
|
{
|
2019-03-06 14:32:51 +01:00
|
|
|
print(20, 1, "K");
|
2019-05-03 17:12:22 +02:00
|
|
|
dupdate();
|
2019-03-06 14:32:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bootlog_driver() - driver load
|
|
|
|
Called for very loaded driver. */
|
|
|
|
void bootlog_driver(const char *drv, const char *status)
|
|
|
|
{
|
|
|
|
/* Positioning for the driver name */
|
|
|
|
|
|
|
|
static int x = 1, y = 4;
|
|
|
|
if(y > 5)
|
|
|
|
{
|
|
|
|
print(21, 4, "+");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
print(x, y, "%3s", drv);
|
|
|
|
x += 4;
|
|
|
|
|
2019-03-10 15:45:34 +01:00
|
|
|
if(x + y >= 22) x=1, y++;
|
2019-03-06 14:32:51 +01:00
|
|
|
|
|
|
|
/* Positioning for the driver message */
|
|
|
|
|
|
|
|
if(!status) return;
|
|
|
|
|
|
|
|
int len = strlen(status);
|
|
|
|
|
|
|
|
static int mx = 1, my = 6;
|
|
|
|
if(mx + len > 22) mx = 1, my++;
|
2019-05-04 19:27:52 +02:00
|
|
|
if(my > 8) return;
|
2019-03-06 14:32:51 +01:00
|
|
|
|
|
|
|
print(mx, my, "%s", status);
|
|
|
|
mx += len + 1;
|
|
|
|
|
|
|
|
dupdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bootlog_driver_summary() - all drivers loaded */
|
|
|
|
void bootlog_driver_summary(void)
|
|
|
|
{
|
|
|
|
int interrupts = 0;
|
|
|
|
uint16_t ipr;
|
|
|
|
print(21, 1, "D");
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
/* Count number of enabled interrupts */
|
|
|
|
if(isSH3()) for(int i = 0; i < 8; i++)
|
2018-08-19 17:11:37 +02:00
|
|
|
{
|
2019-03-06 14:32:51 +01:00
|
|
|
ipr = *SH7705_INTC.IPRS[i];
|
|
|
|
while(ipr > 0)
|
|
|
|
{
|
|
|
|
interrupts += (ipr & 0xf) != 0;
|
|
|
|
ipr >>= 4;
|
|
|
|
}
|
2018-08-19 17:11:37 +02:00
|
|
|
}
|
2019-03-06 14:32:51 +01:00
|
|
|
else for(int i = 0; i < 12; i++)
|
2018-08-19 17:11:37 +02:00
|
|
|
{
|
2019-03-06 14:32:51 +01:00
|
|
|
ipr = SH7305_INTC.IPRS[2 * i];
|
|
|
|
while(ipr > 0)
|
|
|
|
{
|
|
|
|
interrupts += (ipr & 0xf) != 0;
|
|
|
|
ipr >>= 4;
|
|
|
|
}
|
2018-08-19 17:11:37 +02:00
|
|
|
}
|
2018-04-19 13:24:26 +02:00
|
|
|
|
2019-03-06 14:32:51 +01:00
|
|
|
print(19, 5, "#%2d", interrupts);
|
|
|
|
|
2019-02-22 15:08:51 +01:00
|
|
|
dupdate();
|
2018-04-19 13:24:26 +02:00
|
|
|
}
|
2019-05-04 12:07:14 +02:00
|
|
|
|
|
|
|
#endif /* GINT_BOOT_LOG */
|