core: remove bootlog

An unused logging mechanism that was never really fit for its task of
diagnosing boot issues. Disappears with cleanup...
This commit is contained in:
Lephe 2020-06-20 09:46:39 +02:00
parent 9cf2f9fe97
commit de4881244e
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
10 changed files with 10 additions and 390 deletions

3
configure vendored
View File

@ -53,8 +53,6 @@ Build options:
--cflags=FLAGS Additional compiler flags at end of command
Library options (disabled by default):
--boot-log Display a boot debug log at startup if a key is pressed
Used to investigate unstabilities.
--no-syscalls Cut off all syscalls (this will break things)
Only use this option if you have a good idea of which.
--static-gray Allocate gray VRAMs in static RAM instead of the heap
@ -190,7 +188,6 @@ output_config()
echo -n "CONFIG.MACROS ="
echo -n " -D$(echo $target | tr 'a-z' 'A-Z')"
[[ "$boot_log" ]] && echo -n " -DGINT_BOOT_LOG"
[[ "$no_syscalls" ]] && echo -n " -DGINT_NO_SYSCALLS"
[[ "$static_gray" ]] && echo -n " -DGINT_STATIC_GRAY"
[[ "$atexit_max" ]] && echo -n " -DATEXIT_MAX=$atexit_max"

View File

@ -1,40 +0,0 @@
//---
// core:bootlog - Boot-time on-screen log for extreme debugging
//---
#ifndef GINT_CORE_BOOTLOG
#define GINT_CORE_BOOTLOG
#include <gint/defs/attributes.h>
/* bootlog_loaded() - section loading stage
Called when RAM sections have been wiped and copied */
void bootlog_loaded(void);
/* bootlog_mapped() - ROM mapping stage
Called after all ROM pages have been traversed. All of them may not have
been mapped.
@rom Amount of mapped ROM, in bytes
@ram Amount of mapped RAM, in bytes */
void bootlog_mapped(uint32_t rom, uint32_t ram);
/* bootlog_kernel() - gint loading stage
Called when gint has been installed, the VBR switched and the interrupt
handlers set up. */
void bootlog_kernel(void);
/* bootlog_driver() - driver load
Called for very loaded driver. */
void bootlog_driver(const char *driver_name, const char *status);
void bootlog_driver_summary(void);
/* All these functions are enabled only if GINT_BOOT_LOG is defined */
#ifndef GINT_BOOT_LOG
#define bootlog_loaded(...)
#define bootlog_mapped(...)
#define bootlog_kernel(...)
#define bootlog_driver(...)
#define bootlog_driver_summary(...)
#endif
#endif /* GINT_CORE_BOOTLOG */

View File

@ -21,23 +21,19 @@
// 2. ctx_save(sys_ctx)
// 3. init()
//
// Then, if the on-screen boot log is enabled, the status() function is
// called and the returned string is displayed (21 characters max).
// 4. status() [only if GINT_BOOT_LOG is defined]
//
// If the gint_switch() function is called to temporarily give back
// control to the operating system, the state of each driver is saved to
// the stack, then restored from there.
// 5. wait()
// 6. ctx_save(gint_ctx)
// 7. ctx_restore(sys_ctx)
// 4. wait()
// 5. ctx_save(gint_ctx)
// 6. ctx_restore(sys_ctx)
// (stuff happening outside of gint)
// 8. ctx_save(sys_ctx)
// 9. ctx_restore(gint_ctx)
// 7. ctx_save(sys_ctx)
// 8. ctx_restore(gint_ctx)
//
// When finally the driver is unloaded, the system context is restored.
// 10. wait()
// 11. ctx_restore(sys_ctx)
// 9. wait()
// 10. ctx_restore(sys_ctx)
//---
/* gint_driver_t - driver meta-information used by gint */
@ -79,12 +75,6 @@ typedef struct
/* Must restore the state of the driver as saved by ctx_save(). */
void (*ctx_restore)(void *ctx);
/* This function may generate a status string to display on the boot
log for debugging purposes. It should be a short (max 21 bytes)
string because all drivers' strings must fit on a few lines. May
return a pointer to a static buffer. May be NULL. */
char const * (*status)(void);
} GPACKED(4) gint_driver_t;
/* GINT_DECLARE_DRIVER() - make a driver visible to gint
@ -110,15 +100,4 @@ typedef struct
#define GINT_DRIVER_SH3(name) name
#endif
/* GINT_DRIVER_STATUS() - declare a function for status string generation
This macro makes its argument NULL when GINT_BOOT_LOG is undefined, this way
the named function can be defined under #ifdef GINT_BOOT_LOG while keeping
the structure clean. */
#ifdef GINT_BOOT_LOG
#define GINT_DRIVER_STATUS(name) name
#else
#define GINT_DRIVER_STATUS(name) NULL
#endif
#endif /* GINT_DRIVERS */

View File

@ -1,195 +0,0 @@
//---
// gint:core:bootlog - Boot-time on-screen log for extreme debugging
//---
#include <gint/defs/types.h>
#include <gint/std/string.h>
#include <gint/std/stdio.h>
#include <gint/mmu.h>
#include <gint/hardware.h>
#include <gint/mpu/intc.h>
#include <gint/gint.h>
#include <gint/display.h>
#include <gint/clock.h>
#ifdef GINT_BOOT_LOG
#ifdef FXCG50
void Bdisp_AllClr_VRAM(void);
void Bdisp_PutDisp_DD(void);
void PrintXY(int x, int y, const char *str, int fg, int bg);
#define dclear(c) Bdisp_AllClr_VRAM()
#define dupdate() Bdisp_PutDisp_DD()
#endif
/* A copy of the bootlog */
GDATA char gint_bootlog[22*8] = { 0 };
/* Linker script symbols - see core/start.c for details */
extern char
brom, srom,
sgdata, sgbss, sdata, sbss,
btors, mtors, etors;
/* print() - formatted printing shorthand */
static void print(int x, int y, const char *format, ...)
{
char str[45];
va_list args;
va_start(args, format);
vsnprintf(str + 2, 43, format, args);
#ifdef FX9860G
dtext(6 * (x-1) + 1, 8 * (y-1), str + 2, C_BLACK, C_WHITE);
#endif
#ifdef FXCG50
PrintXY(x, y, str, 0, 0);
#endif
memcpy(gint_bootlog + 22 * (y-1) + (x-1), str + 2, strlen(str + 2));
va_end(args);
}
/* bootlog_loaded() - section loading stage */
GSECTION(".pretext")
void bootlog_loaded(void)
{
memset(gint_bootlog, 0x20, 22*8);
for(int i = 0; i < 8; i++) gint_bootlog[22 * i + 21] = 0;
/* Size of memory sections */
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;
/* MPU type */
int mpu = gint[HWMPU];
const char *names = "SH7337\0 SH7305\0 SH7355\0 SH7724";
/* TODO: Use a solid API for boot-time printing */
dclear(C_WHITE);
print(1, 1, "gint @%7x SLmkd", GINT_VERSION);
if(mpu >= 1 && mpu <= 4) print(1, 2, names + 8 * (mpu - 1));
else print(1, 2, "%6d", mpu);
#ifdef FX9860G
print(8, 2, "%c?-", gint[HWRAM] >= (512 << 10) ? 'R' : 'r');
#endif
#ifdef FXCG50
print(8, 2, "---");
#endif
#ifdef FX9860G
char const *osversion = (void *)0x80010020;
char os[11] = { 0 };
for(int i = 0; i < 10; i++) os[i] = osversion[i];
print(12, 2, "OS%2s%2s%4s", os, os+3, os+6);
#endif
print(1, 3, "ROM%4dk RAM%3d+%1dk ??",
(rom_size + 0x3ff) >> 10,
(ram_size + 0x3ff) >> 10,
(gint_size + 0x3ff) >> 10);
dupdate();
}
/* bootlog_mapped() - ROM mapping stage */
GSECTION(".pretext")
void bootlog_mapped(int rom, GUNUSED int ram)
{
/* Check whether all ROM is mapped */
uint32_t rom_size = (uint32_t)&srom;
print(20, 3, "%c%c", (rom >= (int)rom_size) ? 'F' : 'f',
isSH3() ? 'u' : 'U');
print(19, 1, "M");
#ifdef FX9860G
print(9, 2, (ram > 8192) ? "E" : "e");
#endif
dupdate();
}
/* bootlog_kernel() - gint loading stage */
void bootlog_kernel(void)
{
print(20, 1, "K");
dupdate();
}
/* 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;
if(x + y >= 22) x=1, y++;
/* 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++;
if(my > 8) return;
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");
/* Count number of enabled interrupts */
if(isSH3()) for(int i = 0; i < 8; i++)
{
ipr = *SH7705_INTC.IPRS[i];
while(ipr > 0)
{
interrupts += (ipr & 0xf) != 0;
ipr >>= 4;
}
}
else for(int i = 0; i < 12; i++)
{
ipr = SH7305_INTC.IPRS[2 * i];
while(ipr > 0)
{
interrupts += (ipr & 0xf) != 0;
ipr >>= 4;
}
}
print(19, 5, "#%2d", interrupts);
dupdate();
}
#endif /* GINT_BOOT_LOG */

View File

@ -4,7 +4,6 @@
#include <gint/defs/attributes.h>
#include <gint/defs/types.h>
#include <core/bootlog.h>
#include <gint/mmu.h>
#include <gint/drivers.h>
#include <gint/gint.h>
@ -110,11 +109,9 @@ int start(int isappli, int optnum)
regcpy(lxram, sxram, rxram);
regcpy(lyram, syram, ryram);
regclr(rbss, sbss);
bootlog_loaded();
/* Install gint and switch VBR */
gint_install();
bootlog_kernel();
/* We are now running on our own in kernel mode. Since we have taken
control of interrupts, pretty much any interaction with the system
@ -134,13 +131,7 @@ int start(int isappli, int optnum)
if(drv->ctx_save) drv->ctx_save(drv->sys_ctx);
if(drv->init) drv->init();
#ifdef GINT_BOOT_LOG
char const *status = drv->status ? drv->status() : NULL;
bootlog_driver(drv->name, status);
#endif
}
bootlog_driver_summary();
/* With gint fully initialized, we are ready to start the hosted user
application. We have already loaded the RAM sections earlier; all

View File

@ -120,24 +120,6 @@ static void sh7305_probe(void)
// Other driver stuff
//---
#ifdef GINT_BOOT_LOG
#include <gint/std/stdio.h>
static const char *cpg_status(void)
{
static char status[18];
sprintf(status, "I%03d B%03d P%03d C%c",
freq.Iphi_f / 1000000,
freq.Bphi_f / 1000000,
freq.Pphi_f / 1000000,
isSH3() ? 'e' : 'E'
);
return status;
}
#endif /* GINT_BOOT_LOG */
static void init(void)
{
gint[HWCPG] = HW_LOADED;
@ -153,7 +135,6 @@ static void init(void)
gint_driver_t drv_cpg = {
.name = "CPG",
.init = init,
.status = GINT_DRIVER_STATUS(cpg_status),
};
GINT_DECLARE_DRIVER(1, drv_cpg);

View File

@ -245,7 +245,7 @@ int keydown_any(int key, ...)
}
//---
// Driver initialization and status
// Driver initialization
//---
GMAPPED static int callback(GUNUSED volatile void *arg)
@ -277,18 +277,6 @@ static void init(void)
gint[HWKBDSF] = KEYBOARD_SCAN_FREQUENCY;
}
#ifdef GINT_BOOT_LOG
/* keysc_status() - status string of the driver */
static const char *keysc_status(void)
{
static char str[3] = "Sw";
if(isSH3()) str[0] = 's';
return str;
}
#endif /* GINT_BOOT_LOG */
//---
// Driver structure definition
//---
@ -296,7 +284,6 @@ static const char *keysc_status(void)
gint_driver_t drv_keysc = {
.name = "KEYSC",
.init = init,
.status = GINT_DRIVER_STATUS(keysc_status),
};
GINT_DECLARE_DRIVER(4, drv_keysc);

View File

@ -272,27 +272,6 @@ static void init(void)
if(devname == 0x1524) gint[HWDD] |= HWDD_KNOWN;
}
//---
// Driver status string
//---
#ifdef GINT_BOOT_LOG
#include <gint/std/stdio.h>
/* r6524_status() - status string */
static const char *r61524_status(void)
{
select(device_code_read);
uint16_t dev = read();
static char str[8];
sprintf(str, "%04xF-b", dev);
return str;
}
#endif
//---
// Driver structure definition
//---
@ -300,7 +279,6 @@ static const char *r61524_status(void)
gint_driver_t drv_r61524 = {
.name = "R61524",
.init = init,
.status = GINT_DRIVER_STATUS(r61524_status),
.sys_ctx = &sys_ctx,
.gint_ctx = &gint_ctx,
.ctx_save = ctx_save,

View File

@ -163,7 +163,8 @@ void t6k11_backlight(int setting)
/* This setting is mapped to an I/O port:
- On SH3, bit 7 of port G
- On SH4, bit 4 of port N */
- On SH4, bit 4 of port N
TODO: Document the PFC to remove these addresses */
if(isSH3())
{
port = (void *)0xa400012c;
@ -231,21 +232,6 @@ static void init(void)
if(gint[HWCALC] == HWCALC_G35PE2) t6k11_version = 2;
}
//---
// Driver status string
//---
#ifdef GINT_BOOT_LOG
/* t6k11_status() - status string of the driver */
static const char *t6k11_status(void)
{
/* TODO: t6k11: Detect backlight existence */
return "6K11-cB";
}
#endif /* GINT_BOOT_LOG */
//---
// Driver structure definition
//---
@ -253,7 +239,6 @@ static const char *t6k11_status(void)
gint_driver_t drv_t6k11 = {
.name = "T6K11",
.init = init,
.status = GINT_DRIVER_STATUS(t6k11_status),
.sys_ctx = &sys_ctx,
.gint_ctx = &gint_ctx,
.ctx_save = ctx_save,

View File

@ -325,48 +325,6 @@ static void init(void)
}
}
//---
// Status function
//---
#ifdef GINT_BOOT_LOG
/* tmu_status() - status string of extra TMUs for the boot log
The status string has a two-character code for each of the extra timers.
The first character is a digit character describing a value between 0 and 7.
* Bit 0 is set if TCOR=0xffffffff
* Bit 1 is set if TCNT=0xffffffff
* Bit 2 is set if TSTR=0
The second character indicates the status of interrupts.
* "D" (Disabled) if UNIE=0, UNF=0
* "L" (Low) if UNIE=1, UNF=0
* "H" (High) if UNIE=1, UNF=1
* "!" (Error) if UNIE=0, UNF=1
So the normal status string would be made of "7D"'s. */
static const char *tmu_status(void)
{
static char status[18] = "ETMU ";
int j = 5;
for(int i = 0; i < timer_count()-3; i++)
{
etmu_t *T = &ETMU[i];
int v1 = (!(T->TCOR + 1))
| (!(T->TCNT + 1) << 1)
| (!(T->TSTR) << 2);
int v2 = (T->TCR.UNF << 1) | (T->TCR.UNIE);
status[j++] = '0' + v1;
status[j++] = "DLH!"[v2];
}
status[j] = 0;
return status;
}
#endif /* GINT_BOOT_LOG */
//---
// Context system for this driver
//---
@ -444,7 +402,6 @@ gint_driver_t drv_tmu = {
.name = "TMU",
.driver_sh3 = GINT_DRIVER_SH3(driver_sh3),
.init = init,
.status = GINT_DRIVER_STATUS(tmu_status),
.sys_ctx = &sys_ctx,
.gint_ctx = &gint_ctx,
.ctx_save = ctx_save,