RUN Changes
Made RUN an implied command that can pass parameters to the called program.
This commit is contained in:
parent
3509e83475
commit
e0e900e56d
|
@ -425,10 +425,8 @@ short cli_exec(short channel, char * command, int argc, char * argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
// Built in command not found..
|
||||
// TODO: search the current drive for an executable file
|
||||
sys_chan_write(channel, cmd_not_found, strlen(cmd_not_found));
|
||||
return -1;
|
||||
/* No built-in command that matched... try to run a binary file */
|
||||
return cmd_run(channel, argc, argv);
|
||||
}
|
||||
|
||||
char * strtok_r(char * source, const char * delimiter, char ** saveptr) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "syscalls.h"
|
||||
|
@ -153,16 +154,21 @@ short cmd_testcreate(short screen, int argc, char * argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to run a command from storage.
|
||||
*
|
||||
* Command name is in argv[0].
|
||||
*/
|
||||
short cmd_run(short screen, int argc, char * argv[]) {
|
||||
TRACE("cmd_run");
|
||||
|
||||
if (argc > 1) {
|
||||
short result = proc_run(argv[1]);
|
||||
if (result < 0) {
|
||||
log_num(LOG_ERROR, "Unable to run: ", result);
|
||||
return result;
|
||||
}
|
||||
short result = proc_run(argv[0], argc, argv);
|
||||
if (result < 0) {
|
||||
print(screen, "Command not found...\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -249,7 +255,7 @@ short cmd_pwd(short screen, int argc, char * argv[]) {
|
|||
/*
|
||||
* Rename a file or directory
|
||||
*/
|
||||
extern short cmd_rename(short screen, int argc, char * argv[]) {
|
||||
short cmd_rename(short screen, int argc, char * argv[]) {
|
||||
|
||||
TRACE("cmd_rename");
|
||||
|
||||
|
|
5205
src/foenixmcp.s68
5205
src/foenixmcp.s68
File diff suppressed because it is too large
Load diff
|
@ -351,11 +351,16 @@ h_trap_15:
|
|||
; a1 = location to set user stack pointer
|
||||
;
|
||||
_call_user:
|
||||
move.l (4,a7),a0
|
||||
move.l (8,a7),a1
|
||||
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
|
||||
jmp (a0)
|
||||
|
||||
move.l a2,-(a7) ; Push the parameters list
|
||||
move.l d0,-(a7) ; Push the parameter count
|
||||
jsr (a0)
|
||||
|
||||
_restart_cli:
|
||||
lea ___STACK,sp
|
||||
|
|
11030
src/mapfile
11030
src/mapfile
File diff suppressed because it is too large
Load diff
16
src/proc.c
16
src/proc.c
|
@ -10,7 +10,7 @@
|
|||
#include "log.h"
|
||||
#include "dev/fsys.h"
|
||||
|
||||
static const long k_default_stack = 0x0000ffff; /* For now... we're just going to put the user stack under 0x00010000 */
|
||||
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;
|
||||
|
||||
/*
|
||||
|
@ -18,7 +18,7 @@ static int g_proc_result;
|
|||
*/
|
||||
extern void restart_cli();
|
||||
|
||||
extern void call_user(long start, long stack);
|
||||
extern void call_user(long start, long stack, int argc, char * argv[]);
|
||||
|
||||
/*
|
||||
* Start a user mode process
|
||||
|
@ -26,15 +26,17 @@ extern void call_user(long start, long stack);
|
|||
* Inputs:
|
||||
* start = the address to start execution
|
||||
* stack = the location to start the user mode stack
|
||||
* argc = the number of parameters
|
||||
* argv = the array of parameters
|
||||
*/
|
||||
void proc_exec(long start, long stack) {
|
||||
void proc_exec(long start, long stack, int argc, char * argv[]) {
|
||||
TRACE("proc_exec");
|
||||
|
||||
log_num(LOG_INFO, "proc_exec start: ", start);
|
||||
log_num(LOG_INFO, "proc_exec stack: ", stack);
|
||||
|
||||
g_proc_result = 0;
|
||||
call_user(start, stack);
|
||||
call_user(start, stack, argc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -63,11 +65,13 @@ int proc_get_result() {
|
|||
*
|
||||
* Inputs:
|
||||
* path = the path to try to load
|
||||
* argc = the number of parameters
|
||||
* argv = the array of parameters
|
||||
*
|
||||
* Returns:
|
||||
* returns an error code on failure, will not return on success
|
||||
*/
|
||||
short proc_run(const char * path) {
|
||||
short proc_run(const char * path, int argc, char * argv[]) {
|
||||
|
||||
TRACE("proc_run");
|
||||
|
||||
|
@ -79,7 +83,7 @@ short proc_run(const char * path) {
|
|||
short result = fsys_load(path, 0, &start);
|
||||
if (result == 0) {
|
||||
if (start != 0) {
|
||||
proc_exec(start, k_default_stack);
|
||||
proc_exec(start, k_default_stack, argc, argv);
|
||||
} else {
|
||||
log_num(LOG_ERROR, "Couldn't execute file: ", result);
|
||||
return ERR_NOT_EXECUTABLE;
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
* Inputs:
|
||||
* start = the address to start execution
|
||||
* stack = the location to start the user mode stack
|
||||
* argc = the number of parameters
|
||||
* argv = the array of parameters
|
||||
*/
|
||||
extern void proc_exec(long start, long stack);
|
||||
extern void proc_exec(long start, long stack, int argc, char * argv[]);
|
||||
|
||||
/*
|
||||
* Quit the current user process
|
||||
|
@ -39,10 +41,12 @@ extern int proc_get_result();
|
|||
*
|
||||
* Inputs:
|
||||
* path = the path to try to load
|
||||
* argc = the number of parameters
|
||||
* argv = the array of parameters
|
||||
*
|
||||
* Returns:
|
||||
* returns an error code on failure, will not return on success
|
||||
*/
|
||||
extern short proc_run(const char * path);
|
||||
extern short proc_run(const char * path, int argc, char * argv[]);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue