Commit e2e60512 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Updated common Toolbox Makefile fragment.

  Extra shared facilities for object modules.
  Debug support improved.
Detail:
  New common operations for Toolbox object modules have been abstracted
    into this component in order to simplify the object modules.
  Debugging services made common to all modules and now uses DebugLib.
  Common Makefile fragment now exported with correct rules for ROM builds
    as well as RAM builds, and (new in this version), DebugLib RAM builds.
    As a result, all object modules now have debug versions available.
Admin:
  Requires BuildSys 1.92 or later (RiscOS/BuildSys; tag BuildSys-1_92)
  Requires Library 0.41 or later (RiscOS/Library; tag Library-0_41)
  Required by any Toolbox object module dated 4th May 2000 or later.

Version 0.09. Tagged as 'Common-0_09'
parent 9ec92a72
......@@ -42,8 +42,8 @@ WIPE = -wipe
CD = dir
LIBFILE = libfile
CFLAGS = -c -depend !Depend -Wap -zps0 ${INCLUDES} -fah -Fn ${DFLAGS}
CFLAGSZM = -c -depend !Depend -Wap -zps1 ${INCLUDES} -fah -Fn ${DFLAGS} -zM
CFLAGS = -c -depend !Depend -Wap -zps0 ${INCLUDES} -ffah ${DFLAGS}
CFLAGSZM = -c -depend !Depend -Wap -zps1 ${INCLUDES} -ffah ${DFLAGS} -zM
CPFLAGS = ~cfr~v
WFLAGS = ~c~v
LIBFILEFLAGS = -c -o $@
......@@ -74,8 +74,8 @@ DEBUGLIBZM = debuglibm
EXPORTS = ${LIBDIR}.tboxlibint
OBJ = o.mem o.messages o.string32 o.rmensure o.objsupport o.slist o.toolboxmem
OBJZM = z.mem z.messages z.string32 z.rmensure z.objsupport z.slist z.toolboxmem
OBJ = o.mem o.messages o.string32 o.rmensure o.objmodule o.objsupport o.slist o.toolboxmem
OBJZM = z.mem z.messages z.string32 z.rmensure z.objmodule z.objsupport z.slist z.toolboxmem
DBG_OBJ = o.debug
DBG_OBJZM = z.debug
......
......@@ -18,15 +18,15 @@ TBOXINTHDR = -I${TBOXINTLIBDIR}
#
# Build options
#
CFLAGS = -zm -zps1 -ffah -D${SYSTEM}
CINCLUDES = ${TBOXINTHDR} -Itbox: -IC:
CFLAGS += -zm -zps1 -ffah -D${SYSTEM}
CINCLUDES += ${TBOXINTHDR} -Itbox: -IC:
#
# Libraries
#
include Makefiles:ModuleLibs
RAM_LIBS = ${TBOXINTLIB}
ROM_LIBS = ${TBOXINTLIB}
RAM_LIBS = ${TBOXINTLIB} ${EXTRARAMLIBS}
ROM_LIBS = ${TBOXINTLIB} ${EXTRAROMLIBS}
#
# Find the rest of the Makefile fragments for C modules
......@@ -73,9 +73,9 @@ ${RAMMESSAGES}: LocalRes:Messages
${RAMRES}: LocalRes:Res
resgen res_file $@ LocalRes:Res Resources.${COMPONENT}.Res
${RAMBOTH}: LocalRes:Message LocalRes:Res
resgen messages_file $@\
LocalRes:Messages Resources.${COMPONENT}.Messages\
${RAMBOTH}: LocalRes:Messages LocalRes:Res
resgen messages_file $@ \
LocalRes:Messages Resources.${COMPONENT}.Messages \
LocalRes:Res Resources.${COMPONENT}.Res
#
......@@ -83,6 +83,7 @@ ${RAMBOTH}: LocalRes:Message LocalRes:Res
#
toolbox-clean:
${WIPE} o.* ${WFLAGS}
${WIPE} od ${WFLAGS}
${WIPE} aof ${WFLAGS}
${WIPE} rm ${WFLAGS}
${WIPE} linked ${WFLAGS}
......@@ -96,5 +97,30 @@ toolbox-clean:
o.mainROM: main.c
$(CC) ${CFLAGS} -DROM -o $@ main.c
#
# Debug builds of modules
#
DBG_MODULE .= rm.D${COMPONENT}
DBG_OBJS .= ${RAM_OBJS}
DBG_LIBS .= ${RAM_LIBS} C:tboxlibint.o.debuglibm ${DEBUGLIB} ${NET4LIBS}
DBG_DIRS .= od._dirs
${DBG_MODULE}: ${DBG_OBJS} ${DBG_LIBS} ${CLIB} ${DIRS} ${RAM_DEPEND} ${DBG_DIRS}
${MKDIR} rm
${LD} ${LDFLAGS} ${LDRAMFLAGS} -o $@ -rmf ${DBG_OBJS} ${DBG_LIBS} ${CLIB}
trace: ${DBG_MODULE} ${DBG_DIRS}
@echo ${COMPONENT}: debug module built
${DBG_DIRS}:
${MKDIR} od
${TOUCH} $@
.SUFFIXES: .c .s .od
.c.od:; ${CC} ${CFLAGS} -Ddebugging=1 -o $@ $<
.s.od:; ${AS} ${ASFLAGS} -PD "debugging SETA 1" -o $@ $<
EOFTboxMakefile=Common.TboxMake
# EOF
/* (0.08)
/* (0.09)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.08
#define Module_MajorVersion_CMHG 0.09
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 17 Apr 2000
#define Module_Date_CMHG 04 May 2000
#define Module_MajorVersion "0.08"
#define Module_Version 8
#define Module_MajorVersion "0.09"
#define Module_Version 9
#define Module_MinorVersion ""
#define Module_Date "17 Apr 2000"
#define Module_Date "04 May 2000"
#define Module_FullVersion "0.08"
#define Module_FullVersion "0.09"
......@@ -14,183 +14,52 @@
*/
/* File: debug.c
* Purpose: debugging routines for the Toolbox
* Author: Ian Johnson
* History: 16-Sep-93: IDJ: created
* Author: Stewart Brodie
* History: 19-Apr-00: SNB: rewritten to use DebugLib
*
*/
#include "debug.h"
#include "swis.h"
#include "kernel.h"
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#ifndef HostFS_HostVDU
#define HostFS_HostVDU 0x40100
#endif
#ifndef HostFS_TubeVDU
#define HostFS_TubeVDU 0x40101
#endif
#ifndef HostFS_WriteC
#define HostFS_WriteC 0x40102
#endif
static char output_buffer[256];
static char var_val[256] = "";
static char debug_var[256] = "";
static void host_out (char *format, ...);
void debug_dump (void *start, int length) {
_kernel_swi_regs regs;
char buffer[256];
char *address = start;
regs.r[0] = (int)"Hex$Dump";
regs.r[1] = (int)buffer;
regs.r[2] = 255;
regs.r[3] = 0;
regs.r[4] = 3;
_kernel_swi (OS_ReadVarVal, &regs, &regs);
if (regs.r[2] == 0) return;
{
int i, j, k, rows, columns;
int colour, word;
char *ptr,
chr;
enum { black, red, green, yellow, blue, magenta, cyan, white } colours;
char col[8][] = { "\x011\x00", "\x011\x01", "\x011\x02", "\x011\x03",
"\x011\x04", "\x011\x05", "\x011\x06", "\x011\x07"};
buffer[regs.r[2]] = '\0'; /* set correct terminator for end of string */
colour = (int) strstr (buffer, "colour");
word = (int) strstr (buffer, "word");
if ((ptr = strstr (buffer,"R")) == NULL)
rows = 24;
else
sscanf (ptr+1, "%d", &rows);
if (rows<3) rows = 3;
if ((ptr = strstr (buffer,"C")) == NULL)
columns = 16;
else
sscanf (ptr+1, "%d", &columns);
if (columns<4) columns = 4;
ptr = address;
while (ptr < address+length) {
host_out ("\n\r%sAddress ",colour?col[white]:"");
for (j=0;j<columns;j += word?4:1)
if (word)
host_out (" %02x ",(((int)ptr+j) & 0xff));
else
host_out (" %02x",(((int)ptr+j) & 0xff));
host_out (" Characters\n\r");
for (i=0;i<rows-2;i++) {
host_out ("%s%08x%s ",colour?col[cyan]:"",(int)ptr,colour?col[red]:"");
for (j=0;j<columns;j += word?4:1) {
if (ptr+j >= address+length) break;
if (word)
host_out (" %08x",*((int *)(ptr+j)));
else
host_out (" %02x",*(ptr+j));
}
if (j < columns)
for (k=0;k<columns-j;k += word?4:1)
host_out (word?" ":" ");
host_out (" %s",colour?col[magenta]:"");
for (j=0;j<columns;j++) {
if (ptr+j >= address+length) break;
chr = *(ptr+j);
host_out ("%s%c%s",(chr<32?(colour?col[white]:""):""),(chr<32?'.':chr),(chr<32?(colour?col[magenta]:""):""));
}
ptr += j;
host_out ("\n\r");
if (ptr >= address+length) break;
}
}
host_out ("\x014");
}
}
void host_out (char *format, ...) {
va_list args;
char *ptr, buffer[1024];
_kernel_swi_regs regs;
#include "debug.h"
va_start (args, format);
#ifndef DEBUGLIB
# define DEBUGLIB 1
#endif
vsprintf (buffer, format, args);
#undef debug_output
ptr = buffer;
#include "DebugLib/DebugLib.h"
while (*ptr != '\0') {
regs.r[0] = *ptr;
_kernel_swi (HostFS_WriteC, &regs, &regs);
ptr++;
}
va_end (args);
void debug_dump (void *start, int length)
{
(void) start;
(void) length;
ddumpbuf("", start, length, 0);
}
extern void debug_set_var_name (char *var_name)
void debug_set_var_name (char *var_name)
{
strcpy (debug_var, var_name);
static int init_done = 0;
if (!init_done++) {
char sysvar[64];
size_t length = strcspn(var_name, "$");
if (length >= sizeof(sysvar)) length = 62;
strncpy(sysvar, var_name, length);
sysvar[length] = '\0';
debug_initialise(sysvar, NULL, NULL);
}
}
extern void debug_output (char *allow, char *string, ...)
void _common_debug_output (char *allow, char *string, ...)
{
/*
* Function to output the given variable list down the tube. String is a
* printf format string. String is only printed if the given allow string
* appears in the system variable debug_var
*
*/
_kernel_swi_regs regs;
_kernel_oserror *e;
va_list args;
char *p;
va_start(args, string);
regs.r[0] = (int)debug_var;
regs.r[1] = (int)var_val;
regs.r[2] = 255;
regs.r[3] = 0;
regs.r[4] = 3;
_kernel_swi (OS_ReadVarVal, &regs, &regs);
var_val[regs.r[2]] = '\0';
if ((strstr (var_val, allow) != NULL) || !strcmp (allow, "force"))
{
vsprintf (output_buffer, string, args);
for (p = output_buffer; *p != '\0'; p++)
{
if ((*p >= ' ' && *p <= '~') || *p == '\n')
regs.r[0] = (int)*p;
else
regs.r[0] = '*';
_kernel_swi (HostFS_WriteC, &regs, &regs);
if (*p == '\n')
{
regs.r[0] = '\r';
_kernel_swi (HostFS_WriteC, &regs, &regs);
}
}
}
va_list ap;
va_end(args);
va_start(ap, string);
dvprintf((allow, string, ap));
va_end(ap);
}
/* Copyright 2000 Pace Micro Technology plc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Toolbox common library (objmodule.c)
*
* useful utilities for toolbox modules
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "rmensure.h"
#include "objmodule.h"
#include "objects.toolbox.h"
/* Register with the Toolbox module as an object module.
*
* Bit 30 of the flags is used to signal that failure to register with the toolbox module
* on the grounds that the SWI call failed with a SWI not known error should be reported.
* When this bit is not set, such faults will NOT be reported. This allows object modules
* to sleep until such time as a Toolbox modules comes along.
*/
_kernel_oserror *objmodule_register_with_toolbox(int flags, int cls_id, int cls_swi, const char *res)
{
_kernel_oserror *e = _swix(Toolbox_RegisterObjectModule, _INR(0,3),
flags & ~objmodule_REPORT_BAD_SWI, cls_id, cls_swi, res);
if (e && !(flags & objmodule_REPORT_BAD_SWI) && e->errnum == 0x1E6)
e = 0;
return e;
}
_kernel_oserror *objmodule_deregister(int flags, int class_id)
{
return _swix(Toolbox_DeRegisterObjectModule, _INR(0,1), flags, class_id);
}
/* Resource path initialisation */
void objmodule_ensure_path(const char *var, const char *default_setting)
{
if (!getenv(var))
_kernel_setenv(var, default_setting);
}
/* ResourceFS registration/deregistration */
_kernel_oserror *objmodule_register_resources(int resources)
{
return _swix(ResourceFS_RegisterFiles, _IN(0), resources);
}
_kernel_oserror *objmodule_deregister_resources(int resources)
{
return _swix(ResourceFS_DeregisterFiles, _IN(0), resources);
}
......@@ -27,6 +27,8 @@
#endif
#define DEBUG if (!debugging) ; else
#define debug_output _common_debug_output
extern void debug_output (char *allow, char *string, ...);
extern void debug_set_var_name (char *var_name);
extern void debug_dump (void *start, int length);
......
/* Copyright 2000 Pace Micro Technology plc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Toolbox common library (objmodule.h)
*
* useful utilities for toolbox modules
*
*/
#ifndef common_objmodule_h
#define common_objmodule_h
/* Register with the Toolbox module as an object module.
*
* Bit 30 of the flags is used to signal that failure to register with the toolbox module
* on the grounds that the SWI call failed with a SWI not known error should be reported.
* When this bit is not set, such faults will NOT be reported. This allows object modules
* to sleep until such time as a Toolbox modules comes along.
*/
enum {
objmodule_REPORT_BAD_SWI = 1U<<30
};
extern _kernel_oserror *objmodule_register_with_toolbox(int /*flags*/, int /*class*/, int /*swi*/, const char * /*res*/);
extern _kernel_oserror *objmodule_deregister(int /*flags*/, int /*class*/);
/* Resource path initialisation */
extern void objmodule_ensure_path(const char *var, const char *default_setting);
/* ResourceFS registration/deregistration */
extern _kernel_oserror *objmodule_register_resources(int);
extern _kernel_oserror *objmodule_deregister_resources(int);
#endif
......@@ -22,14 +22,6 @@
#ifndef __services_h
#define __services_h
#define Service_Memory 0x11
#define Service_Reset 0x27
#define Service_StartWimp 0x49
#define Service_WimpCloseDown 0x53
#define Service_FilterManagerInstalled 0x87
#define Service_DynamicAreaRenumber 0x92
#include "Global/Services.h"
#endif
......@@ -346,21 +346,4 @@ typedef struct
#define Toolbox_BadMemoryReason (Toolbox_ErrorBase + 0xf)
/* ------------------------------------------- Toolbox Service Calls ---------------------------------- */
#define Service_ToolboxBase (Toolbox_SWIChunkBase+1)
#ifndef Service_ToolboxStarting
#define Service_ToolboxStarting (Service_ToolboxBase + 0)
#endif
#ifndef Service_ToolboxTaskBorn
#define Service_ToolboxTaskBorn (Service_ToolboxBase + 1)
#endif
#ifndef Service_ToolboxTaskDied
#define Service_ToolboxTaskDied (Service_ToolboxBase + 2)
#endif
#ifndef Service_ToolboxDying
#define Service_ToolboxDying (Service_ToolboxBase + 3)
#endif
#endif
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