Commit d59d5712 authored by ROOL's avatar ROOL 🤖
Browse files

This commit was manufactured by cvs2git to create tag 'rthornb_UrsulaBuild- 22Jul1998'.

Sprout from Spinner 1997-03-18 16:19:31 UTC Julian Smith <jsmith@gitlab.riscosopen.org> 'Initial import of ModuleTask library'
Cherrypick from master 1997-05-21 10:52:30 UTC Kevin Bracey <kbracey@gitlab.riscosopen.org> 'Spinner branch merged':
    History
    Makefile
    o/Sources/Sources/c/ModuleTask
    o/Sources/Sources/s/cstart
parent 7ca5c2e9
......@@ -46,3 +46,25 @@ restart the task.
Added 'disable_stack_extension = 1' to start of module runcode
(...c.ModuleTask, function ModuleTask__ModuleEnter()).
25 Mar 1997
Replaced *(int*)"TASK" by 0x4b534154 - the first doesn't work with
MemCheck.CC's -zpc1 flag.
27 Mar 1997
Made MemCheck version. Stack created for USR mode by _blib_entermodule
now has a proper chunk header. Added some extra diagnostics and
checking.
11 Apr 1997
Freeing of _blib_entermodule's stack was incorrect, causing 'Not a heap
block' error when module entry point returned. Fixed.
Stopped claiming Service_Memory - this causes 'Next' slot of application
memory to be used by the module task.
......@@ -47,14 +47,14 @@ export: export_$(PHASE)
export_hdrs:
CDir <Lib$Dir>.$(COMPONENT)
Copy @.h <Lib$Dir>.$(COMPONENT).h $(CopyFlags)
Copy @.$(COMPONENT) <Lib$Dir>.$(COMPONENT).$(COMPONENT) $(CopyFlags)
IfThere @.$(COMPONENT) Then Copy @.$(COMPONENT) <Lib$Dir>.$(COMPONENT).$(COMPONENT) $(CopyFlags)
Echo Library $(COMPONENT): 'export_hdrs' finished.
export_libs:
CDir <Lib$Dir>.$(COMPONENT)
CDir <Lib$Dir>.$(COMPONENT).o
Every.Every2 -c @.o.Sources.!* Obey %0.!Run
Every.Every2 -c "@.o.Sources.!Module.!Run @.o.Sources.!Normal.!Run" Obey %0
Every.Every2 -c @.o.lib* copy %0 <Lib$Dir>.$(COMPONENT).o.%1 $(CopyFlags)
Echo Library $(COMPONENT): 'export_libs' finished.
......
......@@ -16,11 +16,13 @@
#include "Desk.Debug.h"
#include "Desk.Error.h"
#include "Desk.Str.h"
#include "ModuleTask.ModuleTask.h"
#include "Defs.h"
#include "MemCheck.MemCheck.h"
#define TASKHANDLE (*ModuleTask_Client.taskhandle_ptr)
......@@ -32,26 +34,50 @@ _kernel_oserror* ModuleTask__ModuleInitialise( const char *cmd_tail, int podule_
{
_kernel_oserror* e;
MemCheck_InitNoDebug();
MemCheck_RegisterMiscBlock_StringCR( cmd_tail);
/*
{
MemCheck_checking oldchecking = MemCheck_SetChecking( 0, 1);
MemCheck_RegisterMiscBlock( cmd_tail, 1+Desk_strlencr( cmd_tail));
MemCheck_RestoreChecking( oldchecking);
}
*/
Desk_Debug_Assert( ModuleTask_Client.module_initialise);
e = ModuleTask_Client.module_initialise( cmd_tail, podule_base, pw);
if (e) return e;
MemCheck_UnRegisterMiscBlock( cmd_tail);
Desk_Debug_Assert( ModuleTask_Client.taskhandle_ptr);
TASKHANDLE = 0;
return NULL;
}
_kernel_oserror* ModuleTask__ModuleCmdHandler( const char *arg_string, int argc, int cmd_no, void* pw)
{
_kernel_oserror* e = NULL;
Desk_Debug_Printf( Desk_error_PLACE "ModuleTask__ModuleCmdHandler called, cmd_no=%i\n", cmd_no);
MemCheck_RegisterMiscBlock_StringCR( arg_string);
/*
{
MemCheck_checking oldchecking = MemCheck_SetChecking( 0, 1);
MemCheck_RegisterMiscBlock( arg_string, 1+Desk_strlencr( arg_string));
MemCheck_RestoreChecking( oldchecking);
}
*/
if ( cmd_no == ModuleTask_Client.command_desktop_num) {
int startup = 0;
if ( TASKHANDLE == -1) startup = 1;
else if ( TASKHANDLE == 0) {
#ifdef ModuleTask_DESKTOP
/* Check whether wimp is active, and enter module as above if so... */
......@@ -63,7 +89,6 @@ _kernel_oserror* ModuleTask__ModuleCmdHandler( const char *arg_string, int argc,
}
if ( startup) {
_kernel_oserror* e;
Desk_Debug_Printf( Desk_error_PLACE "Just about to enter module\n");
......@@ -74,19 +99,19 @@ _kernel_oserror* ModuleTask__ModuleCmdHandler( const char *arg_string, int argc,
e->errnum, e->errmess
);
else Desk_Debug_Printf( Desk_error_PLACE "ModuleTask__ModuleCmdHandler entering module retunred NULL\n");
return e;
}
else return NULL;
}
if ( ModuleTask_Client.module_commandhandler) return ModuleTask_Client.module_commandhandler( arg_string, argc, cmd_no, pw);
else if ( ModuleTask_Client.module_commandhandler)
return ModuleTask_Client.module_commandhandler( arg_string, argc, cmd_no, pw);
MemCheck_UnRegisterMiscBlock( arg_string);
return NULL;
Desk_UNUSED( arg_string );
Desk_UNUSED( argc );
Desk_UNUSED( pw );
Desk_UNUSED( arg_string);
Desk_UNUSED( argc);
Desk_UNUSED( pw);
}
......@@ -99,6 +124,8 @@ _kernel_oserror* ModuleTask__ModuleCmdHandler( const char *arg_string, int argc,
void ModuleTask__ModuleService( int service_no, _kernel_swi_regs *r, void *pw)
{
MemCheck_RegisterMiscBlock( r, sizeof( *r));
if ( service_no == Service_StartWimp) {
if ( TASKHANDLE == 0) {
TASKHANDLE = -1;
......@@ -111,9 +138,18 @@ void ModuleTask__ModuleService( int service_no, _kernel_swi_regs *r, void *pw)
if ( TASKHANDLE == -1) TASKHANDLE = 0;
}
/* We aren't interested in applicationspace. Used to claim Service_Memory - resulting
in 'next' amount of app memory being used... 11 Apr 1997
We still allow the client to claim this service call though.
*/
/*
else if ( service_no == Service_Memory) {
if ( TASKHANDLE == -1) r->r[1]=0;
//if ( TASKHANDLE == -1) r->r[1]=0;
}
*/
else {
#ifdef Desk_DEBUG
......@@ -128,6 +164,8 @@ void ModuleTask__ModuleService( int service_no, _kernel_swi_regs *r, void *pw)
}
}
MemCheck_UnRegisterMiscBlock( r);
Desk_UNUSED( pw );
}
......@@ -151,7 +189,7 @@ _kernel_oserror* ModuleTask__ModuleFinalise( int fatal, int podule, void* pw)
}
if ( TASKHANDLE > 0) {
e = _swix( Wimp_CloseDown, _INR(0,1), TASKHANDLE, *(int*)"TASK");
e = _swix( Wimp_CloseDown, _INR(0,1), TASKHANDLE, /**(int*)"TASK"*/0x4b534154);
TASKHANDLE = 0; /* Always set taskhandle to 0, so we can always quit after a second attempt, even if the task has gone wrong */
if (e) {
Desk_Debug_Printf( Desk_error_PLACE "ModuleTask__ModuleFinalise: Wimp_CloseDown returned error %i, '%s'\n", e->errnum, e->errmess);
......@@ -184,6 +222,7 @@ extern int disable_stack_extension;
_kernel_oserror* ModuleTask__ModuleEnter( const char *args)
{
Desk_Debug_Printf( Desk_error_PLACE "ModuleTask__ModuleEnter called, taskhandle=0x%08x\n", TASKHANDLE);
Desk_Debug_Assert( ModuleTask_Client.module_enter);
disable_stack_extension = 1;
if ( TASKHANDLE == -1) {
......
......@@ -19,7 +19,7 @@ STACK_SIZE * 8192
OS_Module * &1e
OS_GenerateError * &2b
OS_Exit * &11
STACKCHUNK_HEADERSIZE * 20
IMPORT |_Lib$Reloc$Off$DP|
IMPORT ModuleTask__ModuleEnter
......@@ -39,8 +39,23 @@ OS_Exit * &11
MOV r3,#STACK_SIZE
SWI OS_Module
MOV sl,r2 ; Set up stack
;STR sl,[r7]
ADD sp,sl,r3 ; sp points to first word beyond srack chunk.
; Now set up stack chunk header (_kerne_stack_chunk). JS 27 Mar 1997
LDR r0, stack_magic
STR r0, [ sl, #0] ; sc_mark
MOV r0, #0
STR r0, [ sl, #4] ; sc_next = 0
STR r0, [ sl, #8] ; sc_prev = 0
STR r0, [ sl, #16] ; sc_deallocate = 0
STR r3, [ sl, #12] ; chunk size
;STR r5, [ sl, #STACKCHUNK_HEADERSIZE+0]
;STR r6, [ sl, #STACKCHUNK_HEADERSIZE+4]
ADD sl, sl, #STACKCHUNK_HEADERSIZE
STR sl,[r7]
ADD sp,sl,r3
STMIA sl,{r5,r6}
; This is equivalent of 'ADD r10, r10, #0' + |_Lib$Reloc$Off$DP|
......@@ -55,7 +70,7 @@ OS_Exit * &11
MOV r4,r0
MOV r2,sl
SUB r2, sl, #STACKCHUNK_HEADERSIZE
MOV r0,#7
SWI OS_Module
MOV r0,#0
......@@ -68,5 +83,7 @@ OS_Exit * &11
taskstackptr
DCD ModuleTask__stack
stack_magic
DCD 0xf60690ff
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment