Commit a65ddad5 authored by ROOL's avatar ROOL 🤖

This commit was manufactured by cvs2git to create branch 'Ursula_RiscPC'.

Sprout from Ursula 1998-06-22 13:20:42 UTC ROOL <code@riscosopen.org> 'This commit was manufactured by cvs2git to create branch 'Ursula'.'
Delete:
    Source/LoadCMOS_003/!Mk,fd7
    Source/LoadCMOS_003/!MkClean,fd7
    Source/LoadCMOS_003/!MkInstall,fd7
    Source/LoadCMOS_003/Makefile
    Source/LoadCMOS_003/Resources/!Run,feb
    Source/LoadCMOS_003/Resources/UK/Messages
    Source/LoadCMOS_003/c/main
    Source/LoadCMOS_003/h/main
    Source/LoadCMOS_003/h/util
    Source/LoadCMOS_003/s/util
parent 25d7a1b6
| Copyright 1998 Acorn Computers Ltd
|
| 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.
|
Dir <Obey$Dir>
amu_machine all
| Copyright 1998 Acorn Computers Ltd
|
| 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.
|
Dir <Obey$Dir>
amu_machine clean
| Copyright 1998 Acorn Computers Ltd
|
| 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.
|
Dir <Obey$Dir>
amu_machine install INSTDIR=<Boot$Dir>.Library
# Copyright 1998 Acorn Computers Ltd
#
# 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.
#
# Makefile for LoadCMOS
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 19th Jan 1998 BJGA Created.
# Note, an attribute conflict during link is to be expected.
#
#
# Program-specific options:
#
COMPONENT = LoadCMOS
RDIR = Resources
TARGET = ${RDIR}.!RunImage
OBJS = o.main o.util
LIBS = OSLib:o.OSLib
INCLUDES = -IOS:
#
# Generic options:
#
CC = cc
CFLAGS = -c -depend !Depend -throwback -ffah -apcs 3/noswst
OBJASM = objasm
OFLAGS = -depend !Depend -throwback -apcs 3/noswst
LINK = link
LFLAGS = -o $@ -rmf
SETTYPE = settype
ACCESS = access
ACCFLAGS = WR/R
MKDIR = cdir
CP = copy
CPFLAGS = ~cfr~v
WIPE = wipe
WFLAGS = ~c~v
RM = remove
#
#General rules
#
.SUFFIXES: .o .c .s
.c.o:
${CC} ${CFLAGS} ${INCLUDES} -o $@ $<
.s.o:
${OBJASM} ${OFLAGS} -o $@ $<
#
# External targets:
#
all: ${TARGET}
@echo ${COMPONENT}: make complete
install: all
${MKDIR} ${INSTDIR}.${COMPONENT}
${CP} ${RDIR}.!Run ${INSTDIR}.LoadCMOS.!Run ${CPFLAGS}
${CP} ${TARGET} ${INSTDIR}.LoadCMOS.LoadCMOS ${CPFLAGS}
${CP} ${RDIR}.${LOCALE}.Messages ${INSTDIR}.LoadCMOS.Messages ${CPFLAGS}
|
@echo ${COMPONENT}: installation complete
export:
@echo ${COMPONENT}: export complete
clean:
${WIPE} o.* ${WFLAGS}
${RM} ${TARGET}
@echo ${COMPONENT}: clean complete
#
# Internal targets:
#
${TARGET}: ${OBJS} ${LIBS}
${LINK} ${LFLAGS} ${OBJS} ${LIBS}
${SETTYPE} ${TARGET} Utility
${ACCESS} ${TARGET} ${ACCFLAGS}
#
# Dynamic dependencies:
If "<LoadCMOS$Dir>" = "" then Set LoadCMOS$Dir <Obey$Dir>
/<LoadCMOS$Dir>.LoadCMOS %*0
Info:LoadCMOS version 0.03 20 January 1998
Syntax:Syntax: *LoadCMOS <file>
BadFile:Corrupt CMOS file
BadVer:CMOS file is for a different OS version
/* Copyright 1998 Acorn Computers Ltd
*
* 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.
*/
/*main.c - LOADCMOS *command*/
/*History
When Who What
27 Oct 1994: JRC Written
19 Jan 1998: BJGA Re-written as a transient utility
Functional changes:
* throws errors, rather than writing to stderr
(because we won't be using it from the boot sequence)
* never sets the last-reset-type bit or the checksum byte
* checks for OS version information in file
* checks the checksum stored in the file is valid
20 Jan 1998: BJGA Hourglasses during operation
*/
/* Note, we can't use the SharedCLibrary */
/* from OSLib */
#include "hourglass.h"
#include "messagetrans.h"
#include "os.h"
#include "osargs.h"
#include "osbyte.h"
#include "osfile.h"
#include "osfind.h"
#include "osgbpb.h"
/* local headers */
#include "main.h"
#include "util.h"
/* constants */
#define CMOSxseed 0x01 /* the seed for the checksum calculation */
/* internal error numbers */
#define err_syntax 1
#define err_badfile 2
#define err_badver 3
/* global variables */
static struct
{
char *file;
char argb [os_CLI_LIMIT + 1];
} argl;
static os_error err_out = { 0, "" };
/* prototypes */
static void static_throwerror (int int_err);
/* main_main
* ---------
* Purpose: loads the CMOS from a file
* In: pointers to command, command tail and 1K workspace (as for all Utilities)
* Out: error block pointer
*/
os_error *main_main (const char *cmd, const char *tail, void *wsp)
{
os_error *err = NULL;
fileswitch_object_type obj_type;
int size,
os_version,
file_version,
i,
xsum,
w, /* value to write to CMOS */
r; /* value read from CMOS */
os_f f = 0;
/* Turn on hourglass */
xhourglass_on (); /* it's not integral to the command, so don't panic if returns an error */
/* Parse command line tail */
err = xos_read_args ("file/a", tail, (char *) &argl, sizeof (argl), NULL);
if (err) static_throwerror (err_syntax);
/* Read file details */
err = xosfile_read_stamped_no_path (argl.file, &obj_type, NULL, NULL, &size, NULL, NULL);
if (err) goto finish;
if (!(obj_type & osfile_IS_FILE))
{
err = xosfile_make_error (argl.file, obj_type);
goto finish;
}
/* Invalid file lengths are definitely corrupted */
if (size != 240 && size != 244) static_throwerror (err_badfile);
/* Now find the current OS version */
err = xos_read_var_val ("Boot$OSVersion", &err_out.errmess[0], sizeof (err_out.errmess), 0, os_VARTYPE_EXPANDED, 0, 0, 0);
/* - we might as well use the error buffer to hold the string temporarily */
if (err) goto finish;
err = xos_read_unsigned (10, &err_out.errmess[0], 0, NULL, &os_version);
if (err) goto finish;
/* Old file formats will only be valid pre-Ursula */
if (size == 240 && os_version > 370) static_throwerror (err_badver);
err = xosfind_openin (osfind_NO_PATH | osfind_ERROR_IF_ABSENT | osfind_ERROR_IF_DIR, argl.file, NULL, &f);
if (err) goto finish;
/* Check the file's OS version number (if any) matches the machine */
if (size == 244)
{
err = xosgbpb_read_at (f, (byte *) &file_version, sizeof (file_version), 240, NULL);
if (err) goto finish;
if (file_version != os_version)
{
xosfind_close (f);
static_throwerror (err_badver);
}
err = xosargs_set_ptr (f, 0);
if (err) goto finish;
}
/* Ensure the file's checksum byte is correct */
xsum = CMOSxseed;
for (i = 0; i < 239; i++)
{
err = xosgbpb_read (f, (byte *) &w, 1, NULL); /*(Note that the top 24 bits of |w| are garbage.)*/
if (err) goto finish;
xsum += (w & 0xFF);
}
err = xosgbpb_read (f, (byte *) &w, 1, NULL); /*(Note that the top 24 bits of |w| are garbage.)*/
if (err) goto finish;
if ((xsum & 0xFF) != (w & 0xFF))
{
xosfind_close (f);
static_throwerror (err_badfile);
}
err = xosargs_set_ptr (f, 0);
if (err) goto finish;
/* Actually load the values */
for (i = 0; i < 240; i++)
{
err = xosgbpb_read (f, (byte *) &w, 1, NULL); /*(Note that the top 24 bits of |w| are garbage.)*/
if (err) goto finish;
switch (i)
{
case osbyte_CONFIGURE_DST:
/*Do not load bit 7.*/
err = xos_byte (osbyte_READ_CMOS, i, SKIP, NULL, &r);
if (err) goto finish;
err = xos_byte (osbyte_WRITE_CMOS, i, w & ~osbyte_CONFIGURE_DST_MASK |
r & osbyte_CONFIGURE_DST_MASK, NULL, NULL);
if (err) goto finish;
break;
case osbyte_CONFIGURE_CMOS_RESET:
/*Do not load bit 2.*/
err = xos_byte (osbyte_READ_CMOS, i, SKIP, NULL, &r);
if (err) goto finish;
err = xos_byte (osbyte_WRITE_CMOS, i, w & ~osbyte_CONFIGURE_CMOS_RESET_MASK |
r & osbyte_CONFIGURE_CMOS_RESET_MASK, NULL, NULL);
if (err) goto finish;
break;
case osbyte_CONFIGURE_YEAR0:
case osbyte_CONFIGURE_YEAR1:
case osbyte_CONFIGURE_CHECKSUM:
/*Do nothing - these are never loaded.*/
break;
default:
err = xos_byte (osbyte_WRITE_CMOS, i, w, NULL, NULL);
if (err) goto finish;
break;
}
}
finish:
if (f != 0) xosfind_close (f);
cmd = cmd; /* just to satisfy compiler */
wsp = wsp;
xhourglass_off ();
return err;
}
/* static_throwerror
* -----------------
* Purpose: throws an error local to this utility, with lookup via the Messages file
* In: internal error number
* Out: does not return
*/
static void static_throwerror (int int_err)
{
static messagetrans_control_block mfd;
char *d = &err_out.errmess[0],
*s;
os_error *err;
xhourglass_off ();
switch (int_err)
{
case err_syntax:
s = "Syntax";
break;
case err_badfile:
s = "BadFile";
break;
case err_badver:
s = "BadVer";
break;
default: /* just to satisfy compiler */
s = "Fatal";
}
for (; *s; s++, d++) *d = *s; /* copy string */
err = xmessagetrans_open_file (&mfd, "<LoadCMOS$Dir>.Messages", NULL);
if (!err)
{
err = xmessagetrans_error_lookup (&err_out, &mfd, 0, 0, 0, 0, 0, 0);
xmessagetrans_close_file (&mfd);
}
util_exit (err);
}
/* Copyright 1998 Acorn Computers Ltd
*
* 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.
*/
/* from OSLib */
#include "os.h"
extern os_error *main_main (const char *cmd, const char *tail, void *wsp);
/* Copyright 1998 Acorn Computers Ltd
*
* 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.
*/
/* from OSLib */
#include "os.h"
extern void util_exit (const os_error *e);
; Copyright 1998 Acorn Computers Ltd
;
; 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.
;
sl RN 10
AREA |!!!Utility$Header|, CODE, READONLY
IMPORT __RelocCode
IMPORT main_main
ENTRY
EXPORT util_main
util_main
MOV sl, R12
STR R14, [sl, #0]
STMFD sp!, {a1, a2}
BL __RelocCode
LDMFD sp!, {a1, a2}
ADD a3, sl, #4
BL main_main
EXPORT util_exit
util_exit
LDR R14, [sl]
CMP R0, #0
ORRNES PC, R14, #1<<28
BICEQS PC, R14, #1<<28
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