Added ability for sys_proc_exit to return to a shell program
This commit is contained in:
parent
947c4f96be
commit
a78354c677
|
@ -6,8 +6,8 @@
|
|||
"sys_int_enable","FFE014"
|
||||
"sys_int_register","FFE018"
|
||||
"sys_int_pending","FFE01C"
|
||||
"sys_get_info","FFE020"
|
||||
"sys_int_clear","FFE024"
|
||||
"sys_int_clear","FFE020"
|
||||
"sys_get_info","FFE024"
|
||||
"sys_chan_read_b","FFE028"
|
||||
"sys_chan_read","FFE02C"
|
||||
"sys_chan_readline","FFE030"
|
||||
|
@ -40,35 +40,37 @@
|
|||
"sys_fsys_mkdir","FFE09C"
|
||||
"sys_fsys_delete","FFE0A0"
|
||||
"sys_fsys_rename","FFE0A4"
|
||||
"sys_fsys_set_cwd","FFE0A8"
|
||||
"sys_fsys_get_cwd","FFE0AC"
|
||||
"sys_fsys_load","FFE0B0"
|
||||
"sys_fsys_register_loader","FFE0B4"
|
||||
"sys_fsys_stat","FFE0B8"
|
||||
"sys_mem_get_ramtop","FFE0BC"
|
||||
"sys_mem_reserve","FFE0C0"
|
||||
"sys_time_jiffies","FFE0C4"
|
||||
"sys_rtc_set_time","FFE0C8"
|
||||
"sys_rtc_get_time","FFE0CC"
|
||||
"sys_kbd_scancode","FFE0D0"
|
||||
"sys_err_message","FFE0D4"
|
||||
"sys_kbd_layout","FFE0D8"
|
||||
"sys_proc_run","FFE0DC"
|
||||
"sys_txt_get_capabilities","FFE0E0"
|
||||
"sys_txt_set_mode","FFE0E4"
|
||||
"sys_txt_set_resolution","FFE0E8"
|
||||
"sys_txt_setsizes","FFE0EC"
|
||||
"sys_txt_set_xy","FFE0F0"
|
||||
"sys_txt_get_xy","FFE0F4"
|
||||
"sys_txt_get_region","FFE0F8"
|
||||
"sys_txt_set_region","FFE0FC"
|
||||
"sys_txt_set_color","FFE100"
|
||||
"sys_txt_get_color","FFE104"
|
||||
"sys_txt_set_cursor","FFE108"
|
||||
"sys_txt_set_cursor_visible","FFE10C"
|
||||
"sys_txt_set_font","FFE110"
|
||||
"sys_txt_get_sizes","FFE114"
|
||||
"sys_txt_set_border","FFE118"
|
||||
"sys_txt_set_border_color","FFE11C"
|
||||
"sys_txt_put","FFE120"
|
||||
"sys_txt_print","FFE124"
|
||||
"sys_fsys_load","FFE0A8"
|
||||
"sys_fsys_register_loader","FFE0AC"
|
||||
"sys_fsys_stat","FFE0B0"
|
||||
"sys_mem_get_ramtop","FFE0B4"
|
||||
"sys_mem_reserve","FFE0B8"
|
||||
"sys_time_jiffies","FFE0BC"
|
||||
"sys_rtc_set_time","FFE0C0"
|
||||
"sys_rtc_get_time","FFE0C4"
|
||||
"sys_kbd_scancode","FFE0C8"
|
||||
"sys_err_message","FFE0CC"
|
||||
"sys_kbd_layout","FFE0D0"
|
||||
"sys_proc_run","FFE0D4"
|
||||
"sys_txt_get_capabilities","FFE0D8"
|
||||
"sys_txt_set_mode","FFE0DC"
|
||||
"sys_txt_set_resolution","FFE0E0"
|
||||
"sys_txt_setsizes","FFE0E4"
|
||||
"sys_txt_set_xy","FFE0E8"
|
||||
"sys_txt_get_xy","FFE0EC"
|
||||
"sys_txt_get_region","FFE0F0"
|
||||
"sys_txt_set_region","FFE0F4"
|
||||
"sys_txt_set_color","FFE0F8"
|
||||
"sys_txt_get_color","FFE0FC"
|
||||
"sys_txt_set_cursor","FFE100"
|
||||
"sys_txt_set_cursor_visible","FFE104"
|
||||
"sys_txt_set_font","FFE108"
|
||||
"sys_txt_get_sizes","FFE10C"
|
||||
"sys_txt_set_border","FFE110"
|
||||
"sys_txt_set_border_color","FFE114"
|
||||
"sys_txt_put","FFE118"
|
||||
"sys_txt_print","FFE11C"
|
||||
"sys_kbd_handle_irq","FFE120"
|
||||
"sys_reboot","FFE124"
|
||||
"sys_proc_set_shell","FFE128"
|
||||
"sys_proc_get_result","FFE12C"
|
||||
|
|
|
|
@ -1,6 +1,6 @@
|
|||
.public restart_cli
|
||||
|
||||
.extern cli_rerepl
|
||||
.extern proc_shell_address
|
||||
.extern _Vfp
|
||||
.extern _DirectPageStart
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
|||
;
|
||||
; Reset the stack to the initial value.
|
||||
; Reset the direct page and data bank registers
|
||||
; Restart the CLI
|
||||
; Transfer control to the registered shell address (if present)
|
||||
;
|
||||
restart_cli:
|
||||
rep #0x38 ; 16-bit registers, no decimal mode
|
||||
|
@ -33,5 +33,5 @@ restart_cli:
|
|||
plb ; pop 8 dummy
|
||||
plb ; set data bank
|
||||
|
||||
; jsl cli_rerepl
|
||||
jsl proc_shell_address
|
||||
bra restart_cli
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
.public sys_int_enable
|
||||
.public sys_int_register
|
||||
.public sys_int_pending
|
||||
.public sys_get_info
|
||||
.public sys_int_clear
|
||||
.public sys_get_info
|
||||
.public sys_chan_read_b
|
||||
.public sys_chan_read
|
||||
.public sys_chan_readline
|
||||
|
@ -40,8 +40,6 @@
|
|||
.public sys_fsys_mkdir
|
||||
.public sys_fsys_delete
|
||||
.public sys_fsys_rename
|
||||
.public sys_fsys_set_cwd
|
||||
.public sys_fsys_get_cwd
|
||||
.public sys_fsys_load
|
||||
.public sys_fsys_register_loader
|
||||
.public sys_fsys_stat
|
||||
|
@ -73,6 +71,9 @@
|
|||
.public sys_txt_put
|
||||
.public sys_txt_print
|
||||
.public sys_kbd_handle_irq
|
||||
.public sys_reboot
|
||||
.public sys_proc_set_shell
|
||||
.public sys_proc_get_result
|
||||
|
||||
.extern proc_exit
|
||||
.extern int_enable_all
|
||||
|
@ -82,8 +83,8 @@
|
|||
.extern int_enable
|
||||
.extern int_register
|
||||
.extern int_pending
|
||||
.extern sys_get_information
|
||||
.extern int_clear
|
||||
.extern sys_get_information
|
||||
.extern chan_read_b
|
||||
.extern chan_read
|
||||
.extern chan_readline
|
||||
|
@ -116,8 +117,6 @@
|
|||
.extern fsys_mkdir
|
||||
.extern fsys_delete
|
||||
.extern fsys_rename
|
||||
.extern fsys_set_cwd
|
||||
.extern fsys_get_cwd
|
||||
.extern fsys_load
|
||||
.extern fsys_register_loader
|
||||
.extern fsys_stat
|
||||
|
@ -149,6 +148,9 @@
|
|||
.extern txt_put
|
||||
.extern txt_print
|
||||
.extern kbd_handle_irq
|
||||
.extern reboot
|
||||
.extern proc_set_shell
|
||||
.extern proc_get_result
|
||||
|
||||
.section jumptable
|
||||
|
||||
|
@ -160,8 +162,8 @@ sys_int_disable: jmp long:int_disable
|
|||
sys_int_enable: jmp long:int_enable
|
||||
sys_int_register: jmp long:int_register
|
||||
sys_int_pending: jmp long:int_pending
|
||||
sys_get_info: jmp long:sys_get_information
|
||||
sys_int_clear: jmp long:int_clear
|
||||
sys_get_info: jmp long:sys_get_information
|
||||
sys_chan_read_b: jmp long:chan_read_b
|
||||
sys_chan_read: jmp long:chan_read
|
||||
sys_chan_readline: jmp long:chan_readline
|
||||
|
@ -194,8 +196,6 @@ sys_fsys_set_label: jmp long:fsys_set_label
|
|||
sys_fsys_mkdir: jmp long:fsys_mkdir
|
||||
sys_fsys_delete: jmp long:fsys_delete
|
||||
sys_fsys_rename: jmp long:fsys_rename
|
||||
sys_fsys_set_cwd: jmp long:fsys_set_cwd
|
||||
sys_fsys_get_cwd: jmp long:fsys_get_cwd
|
||||
sys_fsys_load: jmp long:fsys_load
|
||||
sys_fsys_register_loader: jmp long:fsys_register_loader
|
||||
sys_fsys_stat: jmp long:fsys_stat
|
||||
|
@ -226,4 +226,7 @@ sys_txt_set_border: jmp long:txt_set_border
|
|||
sys_txt_set_border_color: jmp long:txt_set_border_color
|
||||
sys_txt_put: jmp long:txt_put
|
||||
sys_txt_print: jmp long:txt_print
|
||||
sys_kbd_handle_irq: jmp long:kbd_handle_irq
|
||||
sys_kbd_handle_irq: jmp long:kbd_handle_irq
|
||||
sys_reboot: jmp long:reboot
|
||||
sys_proc_set_shell: jmp long:proc_set_shell
|
||||
sys_proc_get_result: jmp long:proc_get_result
|
||||
|
|
|
@ -79,3 +79,6 @@ txt_put
|
|||
txt_print
|
||||
|
||||
kbd_handle_irq
|
||||
reboot
|
||||
proc_set_shell
|
||||
proc_get_result
|
||||
|
|
|
@ -202,6 +202,12 @@ extern SYSTEMCALL short sys_int_pending(unsigned short n);
|
|||
*/
|
||||
extern SYSTEMCALL void sys_get_info(p_sys_info info);
|
||||
|
||||
/**
|
||||
* @brief Force the system to reboot
|
||||
*
|
||||
*/
|
||||
extern SYSTEMCALL void sys_reboot();
|
||||
|
||||
/*
|
||||
* Acknowledge an interrupt (clear out its pending flag)
|
||||
*
|
||||
|
@ -774,21 +780,20 @@ extern SYSTEMCALL short sys_kbd_layout(const char * tables);
|
|||
extern SYSTEMCALL short sys_proc_run(const char * path, int argc, char * argv[]);
|
||||
|
||||
/**
|
||||
* Set the value of a variable
|
||||
*
|
||||
* @param name the name of the variable to set
|
||||
* @param value the value the variable should have
|
||||
* @return 0 on success, negative number on error
|
||||
* @brief Set the address of the code that should handle a process exiting
|
||||
*
|
||||
* By default, the address is 0, which means that the system should reboot when the process exits
|
||||
* If any other number is provided, the code at that location will be called as a far call using the
|
||||
* simplecall convention. The first argument will be the return result passed to proc_exit
|
||||
*
|
||||
* @param address the address of the handler code for proc_exit
|
||||
*/
|
||||
extern SYSTEMCALL short sys_var_set(const char *name, const char *value);
|
||||
extern SYSTEMCALL void sys_proc_set_shell(uint32_t address);
|
||||
|
||||
/**
|
||||
* Get the value of a variable
|
||||
*
|
||||
* @param name the name of the variable to set
|
||||
* @return pointer to the string on success, 0 if not found
|
||||
/*
|
||||
* Return the result code of the previously running user process
|
||||
*/
|
||||
extern SYSTEMCALL const char * sys_var_get(const char *name);
|
||||
extern SYSTEMCALL int sys_proc_get_result();
|
||||
|
||||
//
|
||||
// Text screen calls
|
||||
|
|
42
src/proc.c
42
src/proc.c
|
@ -8,15 +8,17 @@
|
|||
|
||||
#include "log_level.h"
|
||||
#ifndef DEFAULT_LOG_LEVEL
|
||||
#define DEFAULT_LOG_LEVEL LOG_ERROR
|
||||
#define DEFAULT_LOG_LEVEL LOG_INFO
|
||||
#endif
|
||||
|
||||
#include "errors.h"
|
||||
#include "log.h"
|
||||
#include "sys_general.h"
|
||||
#include "dev/fsys.h"
|
||||
|
||||
static const long k_default_stack = 0x00010000; /* For now... we're just going to put the user stack under 0x00010000 */
|
||||
static int g_proc_result;
|
||||
static int g_proc_result = 0;
|
||||
uint32_t proc_shell_address = 0;
|
||||
|
||||
/*
|
||||
* Assembly routine: reset the supervisor stack pointer and restart the CLI
|
||||
|
@ -54,6 +56,8 @@ void proc_exec(long start, long stack, int argc, char * argv[]) {
|
|||
call_user(start, stack, argc, argv);
|
||||
}
|
||||
|
||||
typedef void (*thunk)();
|
||||
|
||||
/*
|
||||
* Quit the current user process
|
||||
*
|
||||
|
@ -64,14 +68,40 @@ void proc_exec(long start, long stack, int argc, char * argv[]) {
|
|||
* Inputs:
|
||||
*/
|
||||
SYSTEMCALL void proc_exit(int result) {
|
||||
INFO1("proc_exit: %d", result);
|
||||
g_proc_result = result;
|
||||
restart_cli();
|
||||
if (proc_shell_address != 0) {
|
||||
INFO("proc_exit: Attempting to call into shell");
|
||||
call_user(proc_shell_address, k_default_stack, 0, 0);
|
||||
reboot();
|
||||
|
||||
} else {
|
||||
// Otherwise ask GABE to reset the system
|
||||
INFO("proc_exit: Attempting reboot");
|
||||
reboot();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the result code of the previously running user process
|
||||
/**
|
||||
* @brief Set the address of the code that should handle a process exiting
|
||||
*
|
||||
* By default, the address is 0, which means that the system should reboot when the process exits
|
||||
* If any other number is provided, the code at that location will be called as a far call.
|
||||
*
|
||||
* @param address the address of the handler code for proc_exit
|
||||
*/
|
||||
int proc_get_result() {
|
||||
SYSTEMCALL void proc_set_shell(uint32_t address) {
|
||||
INFO("proc_set_shell")
|
||||
proc_shell_address = address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result code of the previously running user process
|
||||
*
|
||||
* @return the result code of the previously running user process
|
||||
*/
|
||||
SYSTEMCALL int proc_get_result() {
|
||||
INFO("proc_get_result")
|
||||
return g_proc_result;
|
||||
}
|
||||
|
||||
|
|
13
src/proc.h
13
src/proc.h
|
@ -33,10 +33,21 @@ extern void proc_exec(long start, long stack, int argc, char * argv[]);
|
|||
*/
|
||||
extern SYSTEMCALL void proc_exit(int result);
|
||||
|
||||
/**
|
||||
* @brief Set the address of the code that should handle a process exiting
|
||||
*
|
||||
* By default, the address is 0, which means that the system should reboot when the process exits
|
||||
* If any other number is provided, the code at that location will be called as a far call using the
|
||||
* simplecall convention. The first argument will be the return result passed to proc_exit
|
||||
*
|
||||
* @param address the address of the handler code for proc_exit
|
||||
*/
|
||||
extern SYSTEMCALL void proc_set_shell(uint32_t address);
|
||||
|
||||
/*
|
||||
* Return the result code of the previously running user process
|
||||
*/
|
||||
extern int proc_get_result();
|
||||
extern SYSTEMCALL int proc_get_result();
|
||||
|
||||
/*
|
||||
* Find an executable binary matching the path, load it, and execute it
|
||||
|
|
|
@ -321,6 +321,18 @@ SYSTEMCALL void sys_get_information(p_sys_info info) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Force the system to reboot
|
||||
*
|
||||
*/
|
||||
SYSTEMCALL void reboot() {
|
||||
// Authorize GABE to force a CPU reboot and trigger the reboot
|
||||
uint8_t * reboot_auth = (uint8_t *)GABE_RST_AUTH;
|
||||
reboot_auth[0] = 0xde;
|
||||
reboot_auth[1] = 0xad;
|
||||
*GABE_MSTR_CTRL |= GABE_CTRL_WRM_RST;
|
||||
}
|
||||
|
||||
#if MODEL == MODEL_FOENIX_GENX || MODEL == MODEL_FOENIX_A2560X
|
||||
static short genx_leds = 0;
|
||||
|
||||
|
|
|
@ -68,6 +68,12 @@
|
|||
*/
|
||||
extern SYSTEMCALL void sys_get_information(p_sys_info info);
|
||||
|
||||
/**
|
||||
* @brief Force the system to reboot
|
||||
*
|
||||
*/
|
||||
extern SYSTEMCALL void reboot();
|
||||
|
||||
#if MODEL == MODEL_FOENIX_GENX || MODEL == MODEL_FOENIX_A2560X
|
||||
/*
|
||||
* Set the color of the LED for the floppy drive
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
|
||||
#define VER_MAJOR 1
|
||||
#define VER_MINOR 0
|
||||
#define VER_BUILD 33
|
||||
#define VER_BUILD 37
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue