Fix UBC interrupt handler crash + Add UBC menu management + Add programme context menu + Add SH3 opcode

This commit is contained in:
Yann MAGNIN 2019-12-07 15:51:12 +01:00
parent 856bb2ee57
commit 44ace2e56a
21 changed files with 896 additions and 658 deletions

View File

@ -1,40 +0,0 @@
#ifndef __KERNEL_CONTEXT_H__
# define __KERNEL_CONTEXT_H__
#include <stddef.h>
#include <stdint.h>
typedef struct fx9860_context_s
{
struct {
uint16_t control;
uint16_t autofix;
uint16_t scan_mode;
uint16_t scan_state;
uint16_t interrupt;
uint16_t scan_wait;
uint16_t scan_interval;
uint16_t kyoutdr;
uint16_t kyindr;
} keyboard;
struct {
uint16_t ipra;
uint16_t iprb;
uint16_t iprc;
uint16_t iprd;
uint16_t ipre;
uint16_t iprf;
uint16_t iprg;
uint16_t iprh;
uint16_t ipri;
uint16_t iprj;
uint16_t iprk;
uint16_t iprl;
} intc;
} fx9860_context_t;
// Context primitive.
extern void fx9860_context_save(fx9860_context_t *context);
extern void fx9860_context_restore(fx9860_context_t *context);
#endif /*__KERNEL_CONTEXT_H__*/

View File

@ -4,7 +4,7 @@
#include <stddef.h>
#include <stdint.h>
typedef struct ubc_context_s
struct ubc_context_s
{
uint32_t reg[16];
uint32_t gbr;
@ -12,7 +12,22 @@ typedef struct ubc_context_s
uint32_t mach;
uint32_t ssr;
uint32_t spc;
} ubc_context_t;
};
typedef struct ubc_session_s
{
struct {
struct {
uint32_t cursor;
} context;
struct {
uint32_t cursor;
} disassembly;
} menu;
struct ubc_context_s *context;
unsigned int key;
int channel;
} ubc_session_t;
// Primitives.
extern int ubc_open(void);

158
include/kernel/keybios.h Normal file
View File

@ -0,0 +1,158 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : keybios.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __KEYBIOS_H__
#define __KEYBIOS_H__
// Defines
// Character codes
#define KEY_CHAR_0 0x30
#define KEY_CHAR_1 0x31
#define KEY_CHAR_2 0x32
#define KEY_CHAR_3 0x33
#define KEY_CHAR_4 0x34
#define KEY_CHAR_5 0x35
#define KEY_CHAR_6 0x36
#define KEY_CHAR_7 0x37
#define KEY_CHAR_8 0x38
#define KEY_CHAR_9 0x39
#define KEY_CHAR_DP 0x2e
#define KEY_CHAR_EXP 0x0f
#define KEY_CHAR_PMINUS 0x87
#define KEY_CHAR_PLUS 0x89
#define KEY_CHAR_MINUS 0x99
#define KEY_CHAR_MULT 0xa9
#define KEY_CHAR_DIV 0xb9
#define KEY_CHAR_FRAC 0xbb
#define KEY_CHAR_LPAR 0x28
#define KEY_CHAR_RPAR 0x29
#define KEY_CHAR_COMMA 0x2c
#define KEY_CHAR_STORE 0x0e
#define KEY_CHAR_LOG 0x95
#define KEY_CHAR_LN 0x85
#define KEY_CHAR_SIN 0x81
#define KEY_CHAR_COS 0x82
#define KEY_CHAR_TAN 0x83
#define KEY_CHAR_SQUARE 0x8b
#define KEY_CHAR_POW 0xa8
#define KEY_CHAR_IMGNRY 0x7f50
#define KEY_CHAR_LIST 0x7f51
#define KEY_CHAR_MAT 0x7f40
#define KEY_CHAR_EQUAL 0x3d
#define KEY_CHAR_PI 0xd0
#define KEY_CHAR_ANS 0xc0
#define KEY_CHAR_LBRCKT 0x5b
#define KEY_CHAR_RBRCKT 0x5d
#define KEY_CHAR_LBRACE 0x7b
#define KEY_CHAR_RBRACE 0x7d
#define KEY_CHAR_CR 0x0d
#define KEY_CHAR_CUBEROOT 0x96
#define KEY_CHAR_RECIP 0x9b
#define KEY_CHAR_ANGLE 0x7f54
#define KEY_CHAR_EXPN10 0xb5
#define KEY_CHAR_EXPN 0xa5
#define KEY_CHAR_ASIN 0x91
#define KEY_CHAR_ACOS 0x92
#define KEY_CHAR_ATAN 0x93
#define KEY_CHAR_ROOT 0x86
#define KEY_CHAR_POWROOT 0xb8
#define KEY_CHAR_SPACE 0x20
#define KEY_CHAR_DQUATE 0x22
#define KEY_CHAR_VALR 0xcd
#define KEY_CHAR_THETA 0xce
#define KEY_CHAR_A 0x41
#define KEY_CHAR_B 0x42
#define KEY_CHAR_C 0x43
#define KEY_CHAR_D 0x44
#define KEY_CHAR_E 0x45
#define KEY_CHAR_F 0x46
#define KEY_CHAR_G 0x47
#define KEY_CHAR_H 0x48
#define KEY_CHAR_I 0x49
#define KEY_CHAR_J 0x4a
#define KEY_CHAR_K 0x4b
#define KEY_CHAR_L 0x4c
#define KEY_CHAR_M 0x4d
#define KEY_CHAR_N 0x4e
#define KEY_CHAR_O 0x4f
#define KEY_CHAR_P 0x50
#define KEY_CHAR_Q 0x51
#define KEY_CHAR_R 0x52
#define KEY_CHAR_S 0x53
#define KEY_CHAR_T 0x54
#define KEY_CHAR_U 0x55
#define KEY_CHAR_V 0x56
#define KEY_CHAR_W 0x57
#define KEY_CHAR_X 0x58
#define KEY_CHAR_Y 0x59
#define KEY_CHAR_Z 0x5a
// Control codes
#define KEY_CTRL_NOP 0
#define KEY_CTRL_EXE 30004 //0x7534
#define KEY_CTRL_DEL 30025 //0x7549
#define KEY_CTRL_AC 30015 //0x753f
#define KEY_CTRL_FD 30046 //0x755e
#define KEY_CTRL_XTT 30001 //0x7531
#define KEY_CTRL_EXIT 30002 //0x7532
#define KEY_CTRL_SHIFT 30006 //0x7536
#define KEY_CTRL_ALPHA 30007 //0x7537
#define KEY_CTRL_OPTN 30008 //0x7538
#define KEY_CTRL_VARS 30016 //0x7540
#define KEY_CTRL_UP 30018 //0x7542
#define KEY_CTRL_DOWN 30023 //0x7547
#define KEY_CTRL_LEFT 30020 //0x7544
#define KEY_CTRL_RIGHT 30021 //0x7545
#define KEY_CTRL_F1 30009
#define KEY_CTRL_F2 30010
#define KEY_CTRL_F3 30011
#define KEY_CTRL_F4 30012
#define KEY_CTRL_F5 30013
#define KEY_CTRL_F6 30014
#define KEY_CTRL_CATALOG 30100
#define KEY_CTRL_CAPTURE 30055
#define KEY_CTRL_CLIP 30050
#define KEY_CTRL_PASTE 30036
#define KEY_CTRL_INS 30033
#define KEY_CTRL_MIXEDFRAC 30054
#define KEY_CTRL_FRACCNVRT 30026
#define KEY_CTRL_QUIT 30029
#define KEY_CTRL_PRGM 30028
#define KEY_CTRL_SETUP 30037
#define KEY_CTRL_PAGEUP 30052
#define KEY_CTRL_PAGEDOWN 30053
#define KEY_CTRL_MENU 30003
#define KEY_CTRL_RESERVE1 30060
#define KEY_CTRL_RESERVE2 30061
#define KEY_CTRL_RESERVE3 30062
// in Bkey_GetKeyWait function
#define KEYWAIT_HALTON_TIMEROFF 0
#define KEYWAIT_HALTOFF_TIMEROFF 1
#define KEYWAIT_HALTON_TIMERON 2
#define KEYREP_NOEVENT 0
#define KEYREP_KEYEVENT 1
#define KEYREP_TIMEREVENT 2
#endif
#ifdef __cplusplus
}
#endif

21
include/kernel/opcode.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef __OPCODE_H__
# define __OPCODE_H__
#include <stddef.h>
#include <stdint.h>
// Define the number max of arguments
// for intrustions.
#define ARGUMENTS_MAX 3
/* opcode - instruction data part. */
struct opcode_s
{
const char *name;
uint16_t mask;
uint16_t code;
uint16_t arg_mask[ARGUMENTS_MAX];
void (*special)(char *buffer, struct opcode_s);
};
#endif /*__OPCODE_H__*/

View File

@ -19,6 +19,9 @@ struct rect
/* GetKey() - display Casio's VRAM and wait keyboard input. */
void casio_GetKey(unsigned int *key);
/* Bdisp_PutDisp_DD - display Casio's VRAM on screen */
void casio_Bdisp_PutDisp_DD(void);
/* Bdisp_AllClr_VRAM() - clear entirely the Casio's VRAM */
void casio_Bdisp_AllClr_VRAM(void);
@ -26,7 +29,7 @@ void casio_Bdisp_AllClr_VRAM(void);
void casio_Bdisp_AreaClr_VRAM(const struct rect *buf);
/* PrintMini() - print string in Casio's VRAM (and display on screen ?) */
void casio_PrintMini(size_t x, size_t y, char const *str, int mode);
void casio_Bdisp_PrintMini(size_t x, size_t y, char const *str, int mode);
/* Bdisp_DrawLine_VRAM() - draw line in Casio's VRAM. */
void casio_Bdisp_DrawLine_VRAM(int x1, int y1, int x2, int y2);
@ -52,13 +55,5 @@ static inline void dclear_area(int x1, int y1, int x2, int y2)
struct rect area = {.left = x1, .top = y1, .right = x2, .bottom = y2};
casio_Bdisp_AreaClr_VRAM(&area);
}
#define print(x, y, str) casio_PrintMini(x, y, str, 0)
#define getkey casio_GetKey
#define dline_horizontal(y, x1, x2) casio_Bdisp_DrawLine_VRAM(x1, y, x2, y)
#define dclear casio_Bdisp_AllClr_VRAM
#define save_window casio_SaveDisp
#define restore_window casio_RestoreDisp
#define malloc casio_Malloc
#define free casio_Free
#endif /*__CASIO_H__*/

View File

@ -19,6 +19,9 @@
#define DISPLAY_SCREEN_WIDTH 128
#define DISPLAY_SCREEN_HEIGHT 64
#define DISPLAY_VLINES_MAX (DISPLAY_SCREEN_HEIGHT / (KERNEL_FONT_REAL_HEIGHT + 1))
#define DISPLAY_HLINES_MAX (DISPLAY_SCREEN_WIDTH / (KERNEL_FONT_REAL_WIDTH + 1))
// Primtives
extern void dclear(void);
extern void dprint(int x, int y, char const *str, ...);

View File

@ -1,59 +0,0 @@
#include <kernel/context.h>
#include <kernel/hardware/keysc.h>
#include <kernel/hardware/intc.h>
void fx9860_context_save(fx9860_context_t *context)
{
// Save Interrupt Controller (INTC)
context->intc.ipra = SH7305_INTC.IPRA.WORD;
context->intc.iprb = SH7305_INTC.IPRB.WORD;
context->intc.iprc = SH7305_INTC.IPRC.WORD;
context->intc.iprd = SH7305_INTC.IPRD.WORD;
context->intc.ipre = SH7305_INTC.IPRE.WORD;
context->intc.iprf = SH7305_INTC.IPRF.WORD;
context->intc.iprg = SH7305_INTC.IPRG.WORD;
context->intc.iprh = SH7305_INTC.IPRH.WORD;
context->intc.ipri = SH7305_INTC.IPRI.WORD;
context->intc.iprj = SH7305_INTC.IPRJ.WORD;
context->intc.iprk = SH7305_INTC.IPRK.WORD;
context->intc.iprl = SH7305_INTC.IPRL.WORD;
// Save Key Scan (KEYSC) context.
context->keyboard.control = SH7305_KEYSC.CONTROL.WORD;
context->keyboard.autofix = SH7305_KEYSC.AUTOFIX.WORD;
context->keyboard.scan_mode = SH7305_KEYSC.SCAN_MODE.WORD;
context->keyboard.scan_state = SH7305_KEYSC.SCAN_STATE.WORD;
context->keyboard.interrupt = SH7305_KEYSC.INTERRUPT.WORD;
context->keyboard.scan_wait = SH7305_KEYSC.SCAN_WAIT.WORD;
context->keyboard.scan_interval = SH7305_KEYSC.SCAN_INTERVAL;
context->keyboard.kyoutdr = SH7305_KEYSC.KYOUTDR.WORD;
context->keyboard.kyindr = SH7305_KEYSC.KYINDR.WORD;
}
void fx9860_context_restore(fx9860_context_t *context)
{
// Restore Key Scan (KEYSC) context.
SH7305_KEYSC.CONTROL.WORD = context->keyboard.control;
SH7305_KEYSC.AUTOFIX.WORD = context->keyboard.autofix;
SH7305_KEYSC.SCAN_MODE.WORD = context->keyboard.scan_mode;
SH7305_KEYSC.SCAN_STATE.WORD = context->keyboard.scan_state;
SH7305_KEYSC.INTERRUPT.WORD = context->keyboard.interrupt;
SH7305_KEYSC.SCAN_WAIT.WORD = context->keyboard.scan_wait;
SH7305_KEYSC.SCAN_INTERVAL = context->keyboard.scan_interval;
SH7305_KEYSC.KYOUTDR.WORD = context->keyboard.kyoutdr;
SH7305_KEYSC.KYINDR.WORD = context->keyboard.kyindr;
// Restore Interrupt Controller (INTC)
SH7305_INTC.IPRA.WORD = context->intc.ipra;
SH7305_INTC.IPRB.WORD = context->intc.iprb;
SH7305_INTC.IPRC.WORD = context->intc.iprc;
SH7305_INTC.IPRD.WORD = context->intc.iprd;
SH7305_INTC.IPRE.WORD = context->intc.ipre;
SH7305_INTC.IPRF.WORD = context->intc.iprf;
SH7305_INTC.IPRG.WORD = context->intc.iprg;
SH7305_INTC.IPRH.WORD = context->intc.iprh;
SH7305_INTC.IPRI.WORD = context->intc.ipri;
SH7305_INTC.IPRJ.WORD = context->intc.iprj;
SH7305_INTC.IPRK.WORD = context->intc.iprk;
SH7305_INTC.IPRL.WORD = context->intc.iprl;
}

View File

@ -1,49 +0,0 @@
.globl _section_wipe
.global _section_load
.type _section_load, @function
.type _section_wipe, @function
.align 2
/*
** section_map(uint32_t *dest, uint32_t *src, size_t size)
** Load section using his symbols.
*/
_section_load:
shlr2 r6 ! sections are force 4-aligned by the linker.
tst r6, r6 ! check null section...
bt load_loop_end ! ...if null, exit.
load_loop_entry:
mov.l @r5, r1 ! get "src" data.
mov.l r1, @r4 ! copy into the "dest" section.
add #4, r5 ! update "src" address.
dt r6 ! check the load size.
bf/s load_loop_entry ! loop jump.
add #4, r4 ! update "dest" address.
load_loop_end:
rts ! clean exit.
nop ! delayed branch.
/*
** section_wipe(uint32_t *bsection, size_t size)
** Wipe section using his symbols.
*/
_section_wipe:
mov #0, r0 ! wipe data.
shlr2 r5 ! the section force 4-aligned by the linker.
tst r5, r5 ! Check null section...
bt wipe_loop_end ! ...if null, exit !
wipe_loop_entry:
mov.l r0, @r4 ! wipe section part.
dt r5 ! check the section size.
bf/s wipe_loop_entry ! loop jump.
add #4, r4 ! address update.
wipe_loop_end:
rts ! clean exit.
nop ! delayed branch.
.end

View File

@ -1,52 +0,0 @@
#include <stdint.h>
#include <stddef.h>
#include <kernel/hardware/keysc.h>
#include <kernel/hardware/intc.h>
void vhex_context_set(void)
{
// Initialize Interrupt Controller (INTC).
SH7305_INTC.IPRA.WORD = 0x0000;
SH7305_INTC.IPRB.WORD = 0x0000;
SH7305_INTC.IPRC.WORD = 0x0000;
SH7305_INTC.IPRD.WORD = 0x0000;
SH7305_INTC.IPRE.WORD = 0x0000;
SH7305_INTC.IPRF.WORD = 0x0000;
SH7305_INTC.IPRG.WORD = 0x0000;
SH7305_INTC.IPRH.WORD = 0x0000;
SH7305_INTC.IPRI.WORD = 0x0000;
SH7305_INTC.IPRJ.WORD = 0x0000;
SH7305_INTC.IPRK.WORD = 0x0000;
SH7305_INTC.IPRL.WORD = 0x0000;
// Configure Key Scan (KEYSC)
/* SH7305_INTC.IMR5.KEYI = 1; // Mask KEYSC interrupt.
SH7305_INTC.IPRF.KEYSC = 15; // Disable KEYSC interrupt.
SH7305_KEYSC.CONTROL.KEYIE = 0; // Disable KEYSC interrupt during init.
SH7305_KEYSC.CONTROL.INTMODE = 0b00; // Use default (?) interrupt mode.
SH7305_KEYSC.AUTOFIX.ENABLE = 1; // Enable key bounce fix (?)
SH7305_KEYSC.AUTOFIX.UNKNOWN0 = 0b100; // Unknown, use Casio's value. (autofix)
SH7305_KEYSC.AUTOFIX.UNKNOWN1 = 0b10; // Unknown, use Casio's value. (autofix)
SH7305_KEYSC.SCAN_MODE.UNKNOWN0 = 0b000; // Unknown, use Casio's value. (scan mode)
SH7305_KEYSC.SCAN_MODE.UNKNOWN1 = 0b010; // Unknown, use Casio's value. (scan mode)
SH7305_KEYSC.INTERRUPT.KYCPU_IE = 0b0000100; // Interrupt when one key is pressed or released.
SH7305_KEYSC.SCAN_WAIT.TIME = 0x00; // No time between each interrupt.
SH7305_KEYSC.SCAN_INTERVAL = 0x98; // Unknown, use Casio's value. (scan interval)
SH7305_KEYSC.KYOUTDR.KYO5DT = 0b11; // Trigger when high-impedance state is detected.
SH7305_KEYSC.KYOUTDR.KYO4DT = 0b11; // Trigger when high-impedance state is detected.
SH7305_KEYSC.KYOUTDR.KYO3DT = 0b11; // Trigger when high-impedance state is detected.
SH7305_KEYSC.KYOUTDR.KYO2DT = 0b11; // Trigger when high-impedance state is detected.
SH7305_KEYSC.KYOUTDR.KYO1DT = 0b11; // Trigger when high-impedance state is detected.
SH7305_KEYSC.KYOUTDR.KYO0DT = 0b11; // Trigger when high-impedance state is detected.
SH7305_KEYSC.KYINDR.KYDIR6 = 1; // Scan [F1],[SHIFT],[ALPHA],[x,o,T],[div],[7],[4],[1],[0]
SH7305_KEYSC.KYINDR.KYDIR5 = 1; // Scan [F2],[OPT],[^2],[log],[FD],[8],[5],[2],[.]
SH7305_KEYSC.KYINDR.KYDIR4 = 1; // Scan [F3],[VAR],[^],[ln],[(],[9],[6],[3],[x10]
SH7305_KEYSC.KYINDR.KYDIR3 = 1; // Scan [F4],[MENU],[EXIT],[sin],[)],[DEL],[x],[+],[(-)]
SH7305_KEYSC.KYINDR.KYDIR2 = 1; // Scan [F5],[left],[down],[cos],[,],[%],[-],[EXE]
SH7305_KEYSC.KYINDR.KYDIR1 = 1; // Scan [F6],[up],[right],[tan],[->]
SH7305_KEYSC.KYINDR.KYDIR0 = 1; // Scan [AC/ON]
SH7305_KEYSC.CONTROL.KEYIE = 1; // Enable KEYSC interrupt.
SH7305_INTC.IPRF.KEYSC = 15; // Set KEYSC interrupt priority (max).
SH7305_INTC.IMCR5.KEYI = 1; // Clear KEYSC interrupt mask.
*/
}

View File

@ -1,32 +1,39 @@
#include <kernel/devices/ubc.h>
#include <kernel/hardware/ubc.h>
#include <kernel/keybios.h>
#include <kernel/syscall.h>
#include <kernel/extra.h>
#include <lib/display.h>
void ubc_handler(ubc_context_t *context, int channel)
{
unsigned int key;
dclear();
dprint(0, 0,
"UBC INTERRUPT !!!!\n"
"context.spc = %p\n"
"context.ssr = %p\n"
"context.stack = %p\n"
"context = %p\n"
"UBC interrupt = %#x\n"
"Channel = %#x\n",
context->spc,
context->ssr,
context->reg[15],
context,
SH7305_UBC.CCMFR.LONG_WORD,
channel
);
dupdate();
while (1)
// Internal function.
extern void menu_context(ubc_session_t *session);
extern void menu_disassembly(ubc_session_t *session);
void ubc_handler(struct ubc_context_s *context, int channel)
{
void (*menu)(ubc_session_t *session);
ubc_session_t session;
// Initialize new session.
session.key = 0;
session.channel = channel;
session.context = context;
session.menu.context.cursor = 0;
session.menu.disassembly.cursor = 0;
// Initialize menu function.
menu = &menu_disassembly;
// Main loop.
while (session.key != KEY_CTRL_EXIT)
{
casio_GetKey(&key);
menu(&session);
casio_GetKey(&session.key);
switch (session.key)
{
case KEY_CTRL_F1: menu = &menu_disassembly; break;
case KEY_CTRL_F2: menu = &menu_context; break;
}
}
}

View File

@ -8,20 +8,21 @@
.align 2
_ubc_handler_pre:
! Stack management.
stc.l spc, @-r15 ! Save SPC regsiter.
stc.l ssr, @-r15 ! Save SSR regsiter.
.word 0b0100111100110010 ! Save SGR register (save r15 address befor break) "stc.l sgr, @-r15"
mov.l r8, @-r15 ! Save r8 register.
mov.l r9, @-r15 ! Save r9 register.
sts.l pr, @-r15 ! Save pr regsiter.
mov r15, r0 ! Save stack address. (used for UBC context)
! Generate UBC context
mov r15, r1 ! Get current stack address.
add #12, r1 ! Get stack addres "before" UBC interrupt.
stc.l spc, @-r15 ! Get SPC register.
stc.l ssr, @-r15 ! Get SSR register.
sts.l mach, @-r15 ! Get MACH register.
sts.l macl, @-r15 ! Get MACL register.
stc.l gbr, @-r15 ! Get GBR register.
mov.l r1, @-r15 ! Get "program" stack before UBC interrupt.
.word 0b0100111100110010 ! Get SGR register (save r15 address befor break) "stc.l sgr, @-r15"
mov.l r14, @-r15 ! Get r14 register.
mov.l r13, @-r15 ! Get r13 register.
mov.l r12, @-r15 ! Get r12 register.
@ -67,10 +68,15 @@ _ubc_handler_pre:
ldc r9, sr ! Restore SR register (with SR.BL = 1 and SR.IMASK = 0b1111)
! Clean exit.
add r8, r15 ! Restore stack space.
mov r8, r15 ! Restore stack space.
lds.l @r15+, pr ! Restor PR register.
mov.l @r15+, r9 ! Restore r9 register.
mov.l @r15+, r8 ! Restore r8 register.
.word 0b0100111100110110 ! Restore SGR regsiter. "ldc.l @r15+, sgr"
ldc.l @r15+, ssr ! Restore SSR regsiter.
ldc.l @r15+, spc ! Restore SPC regsiter.
rte ! Interrupt Exit.
mov.l @r15+, r8 ! (db) Restore r8 register.
nop ! (db) Safety first.
.align 4

View File

@ -0,0 +1,119 @@
#include <kernel/devices/ubc.h>
#include <kernel/hardware/ubc.h>
#include <kernel/keybios.h>
#include <lib/display.h>
// Menu string format.
const char *content_string[] = {
"!!!! UBC INTERRUPT !!!!",
"Special registers:",
"SPC = %p",
"Stack = %p",
"SSR = %#x",
"\n",
"Generale registers:",
"r0 = %#x",
"r1 = %#x",
"r2 = %#x",
"r3 = %#x",
"r4 = %#x",
"r5 = %#x",
"r6 = %#x",
"r7 = %#x",
"r8 = %#x",
"r9 = %#x",
"r10 = %#x",
"r11 = %#x",
"r12 = %#x",
"r13 = %#x",
"r14 = %#x",
"r15 = %#x",
"\n",
"Debug informations:",
"context = %p",
"UBC interrupt = %#x",
"Channel = %#x",
NULL
};
//
// cursor_update - Update cursor position key pressed based.
// @note:
// Some limits are hard coded so be careful.
//
static void cursor_update(ubc_session_t *session)
{
if (session->key == KEY_CTRL_UP &&
session->menu.context.cursor > 0)
{
session->menu.context.cursor = session->menu.context.cursor - 1;
return;
}
if (session->key == KEY_CTRL_DOWN &&
session->menu.context.cursor < 28 - DISPLAY_VLINES_MAX)
{
session->menu.context.cursor = session->menu.context.cursor + 1;
return;
}
}
//
// menu_context - Show programe context.
// @note:
// This is not the best way to do the job,
// but for now the goal is the create a fonctionnal
// on-calc debugger.
//
void menu_context(ubc_session_t *session)
{
// Menu string data
uint32_t content_data[] = {
0,
0,
session->context->spc,
session->context->reg[15],
session->context->ssr,
0,
0,
session->context->reg[0],
session->context->reg[1],
session->context->reg[2],
session->context->reg[3],
session->context->reg[4],
session->context->reg[5],
session->context->reg[6],
session->context->reg[7],
session->context->reg[8],
session->context->reg[9],
session->context->reg[10],
session->context->reg[11],
session->context->reg[12],
session->context->reg[13],
session->context->reg[14],
session->context->reg[15],
0,
0,
(uint32_t)session->context,
SH7305_UBC.CCMFR.LONG_WORD,
session->channel
};
// Update cursor position.
cursor_update(session);
// Clear VRAM.
dclear();
// Display menu based on cursor position.
for (int i = 0 ; content_string[i + session->menu.context.cursor] != NULL &&
i < DISPLAY_VLINES_MAX ; i = i + 1)
{
dprint(0, i,
content_string[i + session->menu.context.cursor],
content_data[i + session->menu.context.cursor]
);
}
// Display VRAM
dupdate();
}

View File

@ -0,0 +1,10 @@
#include <kernel/devices/ubc.h>
#include <lib/display.h>
void menu_disassembly(ubc_session_t *session)
{
// test
dclear();
dprint(0, 0, "Disassembly Menu !!");
dupdate();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +0,0 @@
.global _t6k11_display
.type _t6k11_display, @function
.text
.align 2
/*
_t6k11_display(void *vram)
This function will display the vram on the screen.
This is the T6K11 drivers, DO NOT USE this function if you are
not absolutly sure that what you are doing.
TODO: use DMA ?
*/
# register organisation:
# r0 Y axis loop.
# r1 LCD register selector.
# r2 LCD data register.
# r3 X axis loop.
# r4 VRAM address.
_t6k11_display:
mov.l r8, @-r15
mov.l r9, @-r15
mov.l 1f, r1
mov.l 2f, r2
mov #4, r6
mov #0, r7
mov #7, r8
mov #192, r5
mov #64, r0
loop_y:
mov.b r6, @r1
mov.b r5, @r2
mov.b r6, @r1
mov.b r7, @r2
mov.b r8, @r1
mov #16, r3
loop_x:
mov.b @r4+, r9
mov.b r9, @r2
dt r3
bf loop_x
dt r0
bf.s loop_y
add #1, r5
mov.l @r15+, r9
rts
mov.l @r15+, r8
.align 4
1: .long 0xb4000000 /* LCD register selector */
2: .long 0xb4010000 /* LCD data register */

View File

@ -1,38 +0,0 @@
/*#include <lib/display.h>
__attribute__((section(".vhex.exception"), interrupt_handler))
void exception_handler(void)
{
uint32_t spc;
uint32_t ssr;
uint32_t sr;
// Get some registers's data.
__asm__ volatile (
"stc spc, %0;"
"stc ssr, %1;"
"stc sr, %2"
: "=r"(spc), "=r"(ssr), "=r"(sr)
:
:
);
// Write exception informations.
dclear();
dprint(0, 0,
"Ho crap ! Exception !\n"
"tra: %#x\n"
"expevt: %#x\n"
"spc: %#x\n"
"ssr: %#x\n"
"sr: %#x",
*((uint32_t *)0xff000020),
*((uint32_t *)0xff000024),
spc,
ssr,
sr
);
dupdate();
while (1);
}*/

View File

@ -1,10 +0,0 @@
/*#include <lib/display.h>
__attribute__((section(".vhex.interrupt"), interrupt_handler))
void interrupt_handler(void)
{
dclear();
dprint(0, 0, "Interrupt handler (%#x)\n", *(uint32_t*)0xff000028);
dupdate();
while (1);
}*/

View File

@ -1,38 +0,0 @@
/*#include <lib/display.h>
__attribute__((section(".glados.tlb"), interrupt_handler))
void tlb_handler(void)
{
uint32_t spc;
uint32_t ssr;
uint32_t sr;
// Get some registers's data.
__asm__ volatile (
"stc spc, %0;"
"stc ssr, %1;"
"stc sr, %2"
: "=r"(spc), "=r"(ssr), "=r"(sr)
:
:
);
// Write exception informations.
dclear();
dprint(0, 0,
"Ho crap ! Exception !\n"
"tra: %#x\n"
"expevt: %#x\n"
"spc: %#x\n"
"ssr: %#x\n"
"sr: %#x",
*((uint32_t *)0xff000020),
*((uint32_t *)0xff000024),
spc,
ssr,
sr
);
dupdate();
while (1);
}*/

View File

@ -16,6 +16,8 @@ void dprint(int x, int y, char const *str, ...)
va_end(ap);
i = -1;
x = x * (KERNEL_FONT_REAL_WIDTH + 1);
y = y * (KERNEL_FONT_REAL_HEIGHT + 1);
default_pos_x = x;
while (buffer[++i] != '\0')
{

View File

@ -1,8 +1,7 @@
#include <lib/display.h>
#include <kernel/hardware/t6k11.h>
#include <kernel/syscall.h>
//FIXME: Check OS 3.00 !
void dupdate(void)
{
t6k11_display(vram);
casio_Bdisp_PutDisp_DD();
}

BIN
vhex.g1a

Binary file not shown.