Fixed file execution from flash

The kernel was unable to start a user mode program when the kernel was in flash. I have changed how the call_user assembly code starts the user mode program to fix this.
This commit is contained in:
Peter Weingartner 2022-04-17 14:29:12 -04:00
parent b315be98b7
commit 31258d63d3
5 changed files with 21 additions and 23 deletions

Binary file not shown.

View file

@ -389,25 +389,22 @@ h_trap_15:
;
; Jump into a user mode code
;
; Inputs:
; a0 = pointer to code to execute
; a1 = location to set user stack pointer
;
_call_user:
; Set up the user stack
move.l #$00010000,a0 ; Get the pointer to the process's stack
move.l (12,a7),d1 ; Get the number of parameters passed
move.l (16,a7),a1 ; Get the pointer to the parameters
move.l a1,-(a0) ; Push the parameters list
move.w d1,-(a0) ; Push the parameter count
move.l a0,usp ; Set the User Stack Pointer
; Set up the system stack
move.l (4,a7),a0 ; Get the pointer to the code to start
move.l (8,a7),a1 ; Get the pointer to the process's stack
move.l (12,a7),d0 ; Get the number of parameters passed
move.l (16,a7),a2 ; Get the pointer to the parameters
andi #$dfff,sr ; Drop into user mode
movea.l a1,a7 ; Set the stack
move.l a2,-(a7) ; Push the parameters list
move.l d0,-(a7) ; Push the parameter count
move.l a2,a1 ; Move argv to a convenient register
move.l d0,d1 ; Move argc to a convenient register
jsr (a0)
move.w #0,-(a7) ; Push the fake vector offset
move.l a0,-(a7) ; Push it as the starting address
move.w #$0000,-(a7) ; Push the user's initial SR (to switch to user mode)
rte ; Start the user process
_restart_cli:
lea ___STACK,sp

View file

@ -3005,11 +3005,11 @@ Symbols of text:
0xffc16c10 _proc_run: global reloc, size 0
0xffc16c4e l24: local reloc, size 0
0xffc16c54 l26: local reloc, size 0
0xffc16c6e l27: local reloc, size 0
0xffc16c8c l28: local reloc, size 0
0xffc16c8e l25: local reloc, size 0
0xffc16caa l30: local reloc, size 0
0xffc16caa l21: local reloc, size 0
0xffc16c70 l27: local reloc, size 0
0xffc16c8e l28: local reloc, size 0
0xffc16c90 l25: local reloc, size 0
0xffc16cac l30: local reloc, size 0
0xffc16cac l21: local reloc, size 0
0xffc16cb4 l29: local reloc, size 0
0xffc16ccc l31: local reloc, size 0
0xffc16ce4 l23: local reloc, size 0

View file

@ -84,6 +84,7 @@ short proc_run(const char * path, int argc, char * argv[]) {
if (result == 0) {
if (start != 0) {
proc_exec(start, k_default_stack, argc, argv);
return 0;
} else {
log_num(LOG_ERROR, "Couldn't execute file: ", result);
return ERR_NOT_EXECUTABLE;

View file

@ -7,6 +7,6 @@
#define VER_MAJOR 0
#define VER_MINOR 51
#define VER_BUILD 6
#define VER_BUILD 7
#endif