Part of the tostools reorganization. All directories now contain a Makefile
and the user interface to the various tools has been standarized.
This commit is contained in:
parent
5b39541e48
commit
783817cc8b
20
sys/arch/atari/stand/tostools/Makefile
Normal file
20
sys/arch/atari/stand/tostools/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# $NetBSD: Makefile,v 1.1 1996/01/07 22:05:31 leo Exp $
|
||||
|
||||
SUBDIR= libtos loadbsd aptck chg_pid rawwrite
|
||||
|
||||
.PHONY: all clean install
|
||||
|
||||
all:
|
||||
@for dir in ${SUBDIR}; do \
|
||||
make -C $$dir all; \
|
||||
done
|
||||
|
||||
clean:
|
||||
@for dir in ${SUBDIR}; do \
|
||||
make -C $$dir clean; \
|
||||
done
|
||||
|
||||
install:
|
||||
@for dir in ${SUBDIR}; do \
|
||||
make -C $$dir install; \
|
||||
done
|
64
sys/arch/atari/stand/tostools/Makefile.inc
Normal file
64
sys/arch/atari/stand/tostools/Makefile.inc
Normal file
@ -0,0 +1,64 @@
|
||||
# $NetBSD: Makefile.inc,v 1.1 1996/01/07 22:05:41 leo Exp $
|
||||
|
||||
#
|
||||
# Configurable stuff.
|
||||
#
|
||||
CC = cc
|
||||
#CC = gcc
|
||||
CPP = cpp
|
||||
#CPP = gcpp
|
||||
#AS = as
|
||||
AS = gas
|
||||
AR = ar rcs
|
||||
RM = rm -f
|
||||
AWK = awk
|
||||
|
||||
#
|
||||
# Any system specific additional libraries.
|
||||
#
|
||||
#LIBS := ${LIBS} -liio -lport
|
||||
LIBS := ${LIBS} -ltermios
|
||||
|
||||
DEBUG =
|
||||
#DEBUG = -g
|
||||
OPTIM = -O
|
||||
#OPTIM = -O2 -fomit-frame-pointer
|
||||
BASREL =
|
||||
#BASREL = -mpcrel -mbaserel
|
||||
STRIP =
|
||||
#STRIP = -Wl,-s
|
||||
|
||||
# End of configuration section.
|
||||
|
||||
|
||||
HEADERS := ${HEADERS} ../libtos/libtos.h
|
||||
LDADD := ${LDADD} ../libtos/libtos.a
|
||||
INCL := ${INCL} -I. -I../libtos
|
||||
DEFS := ${DEFS} -DTOSTOOLS
|
||||
|
||||
CFLAGS := ${CFLAGS} -Wall ${DEBUG} ${BASREL} ${OPTIM} ${INCL}
|
||||
LDFLAGS := ${LDFLAGS} ${DEBUG} ${BASREL} ${STRIP}
|
||||
CPPFLAGS:= ${CPPFLAGS} ${DEFS} ${INCL}
|
||||
|
||||
.PHONY: all clean install
|
||||
|
||||
#
|
||||
# Either ${LIB} or ${PROG} is set.
|
||||
#
|
||||
all: ${LIB} ${PROG}
|
||||
|
||||
clean:
|
||||
${RM} ${LIB} ${PROG} ${OBJS} ${CLEAN} a.out core
|
||||
|
||||
install:
|
||||
# @if [ "${PROG}" ]; then \
|
||||
# ...; \
|
||||
# fi
|
||||
|
||||
${OBJS}: ${HEADERS}
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} ${CPPFLAGS} -o $@ -c $<
|
||||
|
||||
.s.o:
|
||||
${CPP} ${CPPFLAGS} $< | ${AS} ${ASFLAGS} -o $@
|
11
sys/arch/atari/stand/tostools/chg_pid/Makefile
Normal file
11
sys/arch/atari/stand/tostools/chg_pid/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
# $NetBSD: Makefile,v 1.1 1996/01/07 22:06:01 leo Exp $
|
||||
|
||||
PROG = chg_pid.ttp
|
||||
|
||||
OBJS = chg_pid.o
|
||||
HEADERS =
|
||||
|
||||
include ../Makefile.inc
|
||||
|
||||
${PROG}: ${OBJS} ${LDADD}
|
||||
${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} ${LIBS}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chg_pid.c,v 1.1.1.1 1995/03/26 07:12:04 leo Exp $ */
|
||||
/* $NetBSD: chg_pid.c,v 1.2 1996/01/07 22:06:04 leo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 L. Weppelman
|
||||
@ -38,24 +38,44 @@
|
||||
* NBU : NetBSD User partition
|
||||
* NBR : NetBSD Root partition
|
||||
* NBS : NetBSD Swap partition
|
||||
* NBD : General NetBSD partition
|
||||
* RAW : Partition hidden for GEMDOS
|
||||
*
|
||||
* When NetBSD auto boots, the first 'NBR' partition found when scanning the
|
||||
* SCSI-disks becomes the active root partition. The same goes for 'NBS'.
|
||||
* Drives are scanned in 'SCSI-id' order.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <osbind.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "libtos.h"
|
||||
|
||||
#ifndef Dmawrite
|
||||
#define Dmawrite DMAwrite
|
||||
#endif
|
||||
#ifndef Dmaread
|
||||
#define Dmaread DMAread
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Format of GEM root sector
|
||||
*/
|
||||
typedef struct gem_part {
|
||||
u_char p_flg; /* bit 0 is in-use flag */
|
||||
u_char p_id[3]; /* id: GEM, BGM, XGM, UNX, MIX */
|
||||
char p_id[3]; /* id: GEM, BGM, XGM, UNX, MIX */
|
||||
u_long p_st; /* block where partition starts */
|
||||
u_long p_size; /* partition size */
|
||||
} GEM_PART;
|
||||
|
||||
/*
|
||||
* Defines for p_flg
|
||||
*/
|
||||
#define P_VALID 0x01 /* info is valid */
|
||||
#define P_ACTIVE 0x80 /* partition is active */
|
||||
|
||||
#define NGEM_PARTS 4 /* Max. partition infos in root sector */
|
||||
|
||||
typedef struct gem_root {
|
||||
@ -67,146 +87,202 @@ typedef struct gem_root {
|
||||
u_short csum; /* checksum correction */
|
||||
} GEM_ROOT;
|
||||
|
||||
void help PROTO((void));
|
||||
void usage PROTO((void));
|
||||
int chg_tosparts PROTO((int, int, char *));
|
||||
void change_it PROTO((int, GEM_PART *, char *));
|
||||
int read_block PROTO((void *, int, int));
|
||||
int write_block PROTO((void *, int, int));
|
||||
void set_csum PROTO((char *));
|
||||
|
||||
const char version[] = "$Revision: 1.2 $";
|
||||
|
||||
char *Progname = NULL; /* What are we called */
|
||||
int t_flag = 0; /* Test -- don't actually do it */
|
||||
int v_flag = 0; /* show version */
|
||||
int h_flag = 0; /* show help */
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int driveno = 0;
|
||||
int partno = 0;
|
||||
char *newname;
|
||||
/*
|
||||
* Option parsing
|
||||
*/
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
int driveno = 0;
|
||||
int partno = 0;
|
||||
char *newname = NULL;
|
||||
int c;
|
||||
|
||||
if(argc != 4)
|
||||
usage();
|
||||
driveno = atoi(argv[1]);
|
||||
partno = atoi(argv[2]);
|
||||
newname = argv[3];
|
||||
init_toslib(argv[0]);
|
||||
Progname = argv[0];
|
||||
|
||||
printf("Note: drives start numbering at 0!\n");
|
||||
printf("About to change id of partition %d on drive %d to %s\n",
|
||||
partno, driveno, newname);
|
||||
printf("Are you sure (y/n)? ");
|
||||
c = getchar();
|
||||
while ((c = getopt(argc, argv, "htVwo:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
h_flag = 1;
|
||||
break;
|
||||
case 'o':
|
||||
redirect_output(optarg);
|
||||
break;
|
||||
case 't':
|
||||
t_flag = 1;
|
||||
break;
|
||||
case 'V':
|
||||
v_flag = 1;
|
||||
break;
|
||||
case 'w':
|
||||
set_wait_for_key();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (h_flag)
|
||||
help();
|
||||
|
||||
if (v_flag) {
|
||||
eprintf("%s\r\n", version);
|
||||
if (argc != 3)
|
||||
xexit(0);
|
||||
}
|
||||
|
||||
if (argc != 3)
|
||||
usage();
|
||||
|
||||
eprintf("Note: >>> Both drive and partition numbers start "
|
||||
"at 0! <<<\r\n");
|
||||
|
||||
driveno = atoi(argv[0]);
|
||||
partno = atoi(argv[1]);
|
||||
newname = argv[2];
|
||||
eprintf("About to change id of partition %d on drive %d to %s\r\n",
|
||||
partno, driveno, newname);
|
||||
|
||||
if (!t_flag)
|
||||
c = key_wait("Are you sure (y/n)? ");
|
||||
else c = 'y';
|
||||
switch(c) {
|
||||
case 'y':
|
||||
case 'Y':
|
||||
if(chg_tosparts(partno, driveno, newname))
|
||||
printf("Done\n");
|
||||
else printf("Partion number not found\n");
|
||||
if(chg_tosparts(partno, driveno, newname)) {
|
||||
if (!t_flag)
|
||||
eprintf("Done\r\n");
|
||||
else eprintf("Not Done\r\n");
|
||||
xexit(0);
|
||||
}
|
||||
else eprintf("Partition number not found\r\n");
|
||||
break;
|
||||
default :
|
||||
printf("Aborted\n");
|
||||
eprintf("Aborted\r\n");
|
||||
xexit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
printf("Usage: chg_pid <driveno> <partno> <newid>\n");
|
||||
exit(1);
|
||||
xexit(0);
|
||||
}
|
||||
|
||||
int chg_tosparts(chg_part, drive, newname)
|
||||
int chg_part, drive;
|
||||
char *newname;
|
||||
{
|
||||
GEM_ROOT *g_root;
|
||||
GEM_PART g_local[NGEM_PARTS];
|
||||
char buf[512];
|
||||
int pno = 1;
|
||||
int i;
|
||||
GEM_ROOT *g_root;
|
||||
GEM_PART g_local[NGEM_PARTS];
|
||||
char buf[512];
|
||||
int pno = 0;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Read root sector
|
||||
*/
|
||||
if(read_block(buf, 0, drive) == 0) {
|
||||
fprintf(stderr, "Cannot read block 0\n");
|
||||
exit(1);
|
||||
}
|
||||
/*
|
||||
* Read root sector
|
||||
*/
|
||||
if (read_block(buf, 0, drive) == 0)
|
||||
fatal(-1, "Cannot read block 0\r\n");
|
||||
|
||||
/*
|
||||
* Make local copy of partition info, we may need to re-use
|
||||
* the buffer in case of 'XGM' partitions.
|
||||
*/
|
||||
g_root = (GEM_ROOT*)buf;
|
||||
bcopy(g_root->parts, g_local, NGEM_PARTS*sizeof(GEM_PART));
|
||||
/*
|
||||
* Make local copy of partition info, we may need to re-use
|
||||
* the buffer in case of 'XGM' partitions.
|
||||
*/
|
||||
g_root = (GEM_ROOT*)buf;
|
||||
bcopy(g_root->parts, g_local, NGEM_PARTS*sizeof(GEM_PART));
|
||||
|
||||
for (i = 0; i < NGEM_PARTS; i++) {
|
||||
if (!(g_local[i].p_flg & 1))
|
||||
continue;
|
||||
if (!strncmp(g_local[i].p_id, "XGM", 3)) {
|
||||
int j;
|
||||
daddr_t new_root = g_local[i].p_st;
|
||||
|
||||
for(i = 0; i < NGEM_PARTS; i++) {
|
||||
if(!(g_local[i].p_flg & 1))
|
||||
continue;
|
||||
if(!strncmp(g_local[i].p_id, "XGM", 3)) {
|
||||
int j;
|
||||
daddr_t new_root = g_local[i].p_st;
|
||||
|
||||
/*
|
||||
* Loop through extended partition list
|
||||
*/
|
||||
for(;;) {
|
||||
if(read_block(buf, new_root, drive) == 0) {
|
||||
fprintf(stderr, "Cannot read block %d\n", new_root);
|
||||
exit(1);
|
||||
}
|
||||
for(j = 0; j < NGEM_PARTS; j++) {
|
||||
if(!(g_root->parts[j].p_flg & 1))
|
||||
continue;
|
||||
if(!strncmp(g_root->parts[j].p_id, "XGM", 3)) {
|
||||
new_root = g_local[i].p_st + g_root->parts[j].p_st;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if(pno == chg_part) {
|
||||
change_it(pno,g_root->parts[j].p_id, newname);
|
||||
if(write_block(buf, new_root, drive) == 0) {
|
||||
fprintf(stderr, "Cannot write block %d\n",
|
||||
new_root);
|
||||
exit(1);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
pno++;
|
||||
}
|
||||
}
|
||||
if(j == NGEM_PARTS)
|
||||
/*
|
||||
* Loop through extended partition list
|
||||
*/
|
||||
for(;;) {
|
||||
if (read_block(buf, new_root, drive) == 0)
|
||||
fatal(-1, "Cannot read block %d\r\n", new_root);
|
||||
for (j = 0; j < NGEM_PARTS; j++) {
|
||||
if (!(g_root->parts[j].p_flg & 1))
|
||||
continue;
|
||||
if (!strncmp(g_root->parts[j].p_id, "XGM", 3)) {
|
||||
new_root = g_local[i].p_st + g_root->parts[j].p_st;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(pno == chg_part) {
|
||||
/*
|
||||
* Re-read block 0
|
||||
*/
|
||||
if(read_block(buf, 0, drive) == 0) {
|
||||
fprintf(stderr, "Cannot read block 0\n");
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
if (pno == chg_part) {
|
||||
change_it(pno, &g_root->parts[j], newname);
|
||||
if (t_flag)
|
||||
return(1);
|
||||
if (write_block(buf, new_root, drive) == 0)
|
||||
fatal(-1, "Cannot write block %d\r\n",new_root);
|
||||
return(1);
|
||||
}
|
||||
change_it(pno, g_root->parts[i].p_id, newname);
|
||||
set_csum(buf);
|
||||
if(write_block(buf, 0, drive) == 0) {
|
||||
fprintf(stderr, "Cannot write block 0\n");
|
||||
exit(1);
|
||||
}
|
||||
return(1);
|
||||
pno++;
|
||||
}
|
||||
}
|
||||
pno++;
|
||||
if (j == NGEM_PARTS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
else {
|
||||
if (pno == chg_part) {
|
||||
/*
|
||||
* Re-read block 0
|
||||
*/
|
||||
if (read_block(buf, 0, drive) == 0)
|
||||
fatal(-1, "Cannot read block 0\r\n");
|
||||
change_it(pno, &g_root->parts[i], newname);
|
||||
if (t_flag)
|
||||
return(1);
|
||||
set_csum(buf);
|
||||
if (write_block(buf, 0, drive) == 0)
|
||||
fatal(-1, "Cannot write block 0\r\n");
|
||||
return(1);
|
||||
}
|
||||
pno++;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
change_it(pno, p_id, newname)
|
||||
int pno;
|
||||
char *p_id, *newname;
|
||||
void change_it(pno, gp, newname)
|
||||
int pno;
|
||||
GEM_PART *gp;
|
||||
char *newname;
|
||||
{
|
||||
char s1[4], s2[4];
|
||||
|
||||
strncpy(s1, p_id, 3);
|
||||
strncpy(s1, gp->p_id, 3);
|
||||
strncpy(s2, newname, 3);
|
||||
s1[3] = s2[3] = '\0';
|
||||
printf("Changing partition %d: %s -> %s ...", pno, s1, s2);
|
||||
p_id[0] = s2[0]; p_id[1] = s2[1]; p_id[2] = s2[2];
|
||||
eprintf("Changing partition %d: %s -> %s ...", pno, s1, s2);
|
||||
gp->p_id[0] = s2[0]; gp->p_id[1] = s2[1]; gp->p_id[2] = s2[2];
|
||||
}
|
||||
|
||||
read_block(buf, blkno, drive)
|
||||
int read_block(buf, blkno, drive)
|
||||
void *buf;
|
||||
int blkno;
|
||||
int drive;
|
||||
@ -216,7 +292,7 @@ int drive;
|
||||
return(1);
|
||||
}
|
||||
|
||||
write_block(buf, blkno, drive)
|
||||
int write_block(buf, blkno, drive)
|
||||
void *buf;
|
||||
int blkno;
|
||||
int drive;
|
||||
@ -226,7 +302,7 @@ int drive;
|
||||
return(1);
|
||||
}
|
||||
|
||||
set_csum(buf)
|
||||
void set_csum(buf)
|
||||
char *buf;
|
||||
{
|
||||
unsigned short *p = (unsigned short *)buf;
|
||||
@ -238,3 +314,35 @@ char *buf;
|
||||
csum += *p++;
|
||||
*--p = (0x1234 - csum) & 0xffff;
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
eprintf("Usage: %s [-hVwt] [ -o <output file>] <driveno> <partno> "
|
||||
"<newid>\r\n", Progname);
|
||||
xexit(1);
|
||||
}
|
||||
|
||||
void
|
||||
help()
|
||||
{
|
||||
eprintf("\r
|
||||
Change partition identifiers\r
|
||||
\r
|
||||
Usage: %s [-hVwt] [ -o <output file>] <driveno> <partno> <newid>\r
|
||||
\r
|
||||
Description of options:\r
|
||||
\r
|
||||
\t-h What your getting right now.\r
|
||||
\t-o Write output to both <output file> and stdout.\r
|
||||
\t-V Print program version.\r
|
||||
\t-w Wait for a keypress before exiting.\r
|
||||
\t-t Test mode. It does everyting except the modifications on disk.\r
|
||||
\r
|
||||
The <driveno> and <partno> arguments specify the drive and the partition\r
|
||||
this program acts on. Both are zero based.\r
|
||||
The <newid> argument specifies a 3 letter string that will become the new\r
|
||||
partition-id.\r
|
||||
Finally note that the actions of %s are reversable.\r
|
||||
", Progname, Progname);
|
||||
xexit(0);
|
||||
}
|
||||
|
11
sys/arch/atari/stand/tostools/loadbsd/Makefile
Normal file
11
sys/arch/atari/stand/tostools/loadbsd/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
# $NetBSD: Makefile,v 1.1 1996/01/07 22:06:13 leo Exp $
|
||||
|
||||
PROG = loadbsd.ttp
|
||||
|
||||
OBJS = loadbsd.o
|
||||
HEADERS = loader.h ../libtos/kparamb.h
|
||||
|
||||
include ../Makefile.inc
|
||||
|
||||
${PROG}: ${OBJS} ${LDADD}
|
||||
${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} ${LIBS}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: loadbsd.c,v 1.9 1995/09/23 20:31:21 leo Exp $ */
|
||||
/* $NetBSD: loadbsd.c,v 1.10 1996/01/07 22:06:15 leo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 L. Weppelman
|
||||
@ -34,45 +34,40 @@
|
||||
* NetBSD loader for the Atari-TT.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <a_out.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <osbind.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "libtos.h"
|
||||
#include "loader.h"
|
||||
|
||||
char *Progname; /* How are we called */
|
||||
int t_flag = 0; /* Just test, do not execute */
|
||||
int d_flag = 0; /* Output debugging output? */
|
||||
int s_flag = 0; /* St-ram only */
|
||||
int d_flag = 0; /* Output debugging output? */
|
||||
int h_flag = 0; /* show help */
|
||||
int s_flag = 0; /* St-ram only */
|
||||
int t_flag = 0; /* Just test, do not execute */
|
||||
int v_flag = 0; /* show version */
|
||||
|
||||
char version[] = "$Revision: 1.9 $";
|
||||
const char version[] = "$Revision: 1.10 $";
|
||||
|
||||
/*
|
||||
* Default name of kernel to boot, large enough to patch
|
||||
*/
|
||||
char kname[80] = "n:/netbsd";
|
||||
char kname[80] = "n:/netbsd";
|
||||
|
||||
static struct {
|
||||
u_char *kp; /* 00: Kernel load address */
|
||||
long ksize; /* 04: Size of loaded kernel */
|
||||
u_long entry; /* 08: Kernel entry point */
|
||||
long stmem_size; /* 12: Size of st-ram */
|
||||
long ttmem_size; /* 16: Size of tt-ram */
|
||||
long cputype; /* 20: Type of cpu */
|
||||
long boothowto; /* 24: How to boot */
|
||||
long ttmem_start; /* 28: Start of tt-ram */
|
||||
long esym_loc; /* 32: End of symbol table */
|
||||
} kparam;
|
||||
static struct kparamb kparam;
|
||||
|
||||
void get_sys_info(void);
|
||||
void error(char *fmt, ...);
|
||||
void help(void);
|
||||
void usage(void);
|
||||
void start_kernel(void);
|
||||
void do_exit(int);
|
||||
void help PROTO((void));
|
||||
void usage PROTO((void));
|
||||
void get_sys_info PROTO((void));
|
||||
void start_kernel PROTO((void));
|
||||
|
||||
int main(argc, argv)
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
@ -86,12 +81,13 @@ char **argv;
|
||||
long textsz, stringsz;
|
||||
struct exec ehdr;
|
||||
|
||||
init_toslib(argv[0]);
|
||||
Progname = argv[0];
|
||||
|
||||
kparam.boothowto = RB_SINGLE;
|
||||
|
||||
while ((ch = getopt(argc, argv, "abdhstvDS:T:")) != EOF) {
|
||||
switch(ch) {
|
||||
while ((ch = getopt(argc, argv, "abdhstVwDo:S:T:")) != EOF) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
kparam.boothowto &= ~(RB_SINGLE);
|
||||
kparam.boothowto |= RB_AUTOBOOT;
|
||||
@ -105,6 +101,12 @@ char **argv;
|
||||
case 'D':
|
||||
d_flag = 1;
|
||||
break;
|
||||
case 'h':
|
||||
h_flag = 1;
|
||||
break;
|
||||
case 'o':
|
||||
redirect_output(optarg);
|
||||
break;
|
||||
case 's':
|
||||
s_flag = 1;
|
||||
break;
|
||||
@ -117,20 +119,26 @@ char **argv;
|
||||
case 'T':
|
||||
kparam.ttmem_size = atoi(optarg);
|
||||
break;
|
||||
case 'v':
|
||||
fprintf(stdout,"%s\r\n", version);
|
||||
case 'V':
|
||||
v_flag = 1;
|
||||
break;
|
||||
case 'w':
|
||||
set_wait_for_key();
|
||||
break;
|
||||
case 'h':
|
||||
help();
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if(argc == 1)
|
||||
if (argc == 1)
|
||||
strcpy(kname, argv[0]);
|
||||
|
||||
if (h_flag)
|
||||
help();
|
||||
if (v_flag)
|
||||
eprintf("%s\r\n", version);
|
||||
|
||||
/*
|
||||
* Get system info to pass to NetBSD
|
||||
*/
|
||||
@ -139,12 +147,12 @@ char **argv;
|
||||
/*
|
||||
* Find the kernel to boot and read it's exec-header
|
||||
*/
|
||||
if((fd = open(kname, O_RDONLY)) < 0)
|
||||
error("Cannot open kernel '%s'", kname);
|
||||
if(read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
|
||||
error("Cannot read exec-header of '%s'", kname);
|
||||
if((ehdr.a_magic & 0xffff) != NMAGIC) /* XXX */
|
||||
error("Not an NMAGIC file '%s'", kname);
|
||||
if ((fd = open(kname, O_RDONLY)) < 0)
|
||||
fatal(-1, "Cannot open kernel '%s'", kname);
|
||||
if (read(fd, (char *)&ehdr, sizeof(ehdr)) != sizeof(ehdr))
|
||||
fatal(-1, "Cannot read exec-header of '%s'", kname);
|
||||
if (N_MAGIC(ehdr) != NMAGIC)
|
||||
fatal(-1, "Not an NMAGIC file '%s'", kname);
|
||||
|
||||
/*
|
||||
* Extract various sizes from the kernel executable
|
||||
@ -154,69 +162,70 @@ char **argv;
|
||||
kparam.ksize = textsz + ehdr.a_data + ehdr.a_bss;
|
||||
kparam.entry = ehdr.a_entry;
|
||||
|
||||
if(ehdr.a_syms) {
|
||||
if(lseek(fd,ehdr.a_text+ehdr.a_data+ehdr.a_syms+sizeof(ehdr), 0) <= 0)
|
||||
error("Cannot seek to string table in '%s'", kname);
|
||||
if(read(fd, &stringsz, sizeof(long)) != sizeof(long))
|
||||
error("Cannot read string-table size");
|
||||
if(lseek(fd, sizeof(ehdr), 0) <= 0)
|
||||
error("Cannot seek back to text start");
|
||||
if (ehdr.a_syms) {
|
||||
if (lseek(fd,ehdr.a_text+ehdr.a_data+ehdr.a_syms+sizeof(ehdr),0) <= 0)
|
||||
fatal(-1, "Cannot seek to string table in '%s'", kname);
|
||||
if (read(fd, (char *)&stringsz, sizeof(long)) != sizeof(long))
|
||||
fatal(-1, "Cannot read string-table size");
|
||||
if (lseek(fd, sizeof(ehdr), 0) <= 0)
|
||||
fatal(-1, "Cannot seek back to text start");
|
||||
kparam.ksize += ehdr.a_syms + sizeof(long) + stringsz;
|
||||
}
|
||||
|
||||
if((kparam.kp = (u_char *)malloc(kparam.ksize)) == NULL)
|
||||
error("Cannot malloc kernel image space");
|
||||
if ((kparam.kp = (u_char *)malloc(kparam.ksize)) == NULL)
|
||||
fatal(-1, "Cannot malloc kernel image space");
|
||||
|
||||
/*
|
||||
* Read text & data, clear bss
|
||||
*/
|
||||
if((read(fd, kparam.kp, ehdr.a_text) != ehdr.a_text)
|
||||
|| (read(fd, kparam.kp + textsz, ehdr.a_data) != ehdr.a_data))
|
||||
error("Unable to read kernel image\n");
|
||||
if ((read(fd, (char *)kparam.kp, ehdr.a_text) != ehdr.a_text)
|
||||
|| (read(fd,(char *)(kparam.kp+textsz),ehdr.a_data) != ehdr.a_data))
|
||||
fatal(-1, "Unable to read kernel image\n");
|
||||
memset(kparam.kp + textsz + ehdr.a_data, 0, ehdr.a_bss);
|
||||
|
||||
/*
|
||||
* Read symbol and string table
|
||||
*/
|
||||
if(ehdr.a_syms) {
|
||||
if (ehdr.a_syms) {
|
||||
long *p;
|
||||
|
||||
p = (long *)(kparam.kp + textsz + ehdr.a_data + ehdr.a_bss);
|
||||
*p++ = ehdr.a_syms;
|
||||
if(read(fd, (char *)p, ehdr.a_syms) != ehdr.a_syms)
|
||||
error("Cannot read symbol table\n");
|
||||
if (read(fd, (char *)p, ehdr.a_syms) != ehdr.a_syms)
|
||||
fatal(-1, "Cannot read symbol table\n");
|
||||
p = (long *)((char *)p + ehdr.a_syms);
|
||||
if(read(fd, (char *)p, stringsz) != stringsz)
|
||||
error("Cannot read string table\n");
|
||||
if (read(fd, (char *)p, stringsz) != stringsz)
|
||||
fatal(-1, "Cannot read string table\n");
|
||||
kparam.esym_loc = (long)((char *)p-(char *)kparam.kp +stringsz);
|
||||
}
|
||||
|
||||
if(d_flag) {
|
||||
fprintf(stdout, "\r\nKernel info:\r\n");
|
||||
fprintf(stdout, "Kernel loadaddr\t: 0x%08x\r\n", kparam.kp);
|
||||
fprintf(stdout, "Kernel size\t: %10d bytes\r\n", kparam.ksize);
|
||||
fprintf(stdout, "Kernel entry\t: 0x%08x\r\n", kparam.entry);
|
||||
fprintf(stdout, "Kernel esym\t: 0x%08x\r\n", kparam.esym_loc);
|
||||
if (d_flag) {
|
||||
eprintf("\r\nKernel info:\r\n");
|
||||
eprintf("Kernel loadaddr\t: 0x%08x\r\n", kparam.kp);
|
||||
eprintf("Kernel size\t: %10d bytes\r\n", kparam.ksize);
|
||||
eprintf("Kernel entry\t: 0x%08x\r\n", kparam.entry);
|
||||
eprintf("Kernel esym\t: 0x%08x\r\n", kparam.esym_loc);
|
||||
}
|
||||
|
||||
if(!t_flag)
|
||||
if (!t_flag)
|
||||
start_kernel();
|
||||
/* NOT REACHED */
|
||||
|
||||
fprintf(stdout, "Kernel '%s' was loaded OK\r\n", kname);
|
||||
do_exit(0);
|
||||
eprintf("Kernel '%s' was loaded OK\r\n", kname);
|
||||
xexit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract memory and cpu/fpu info from system.
|
||||
*/
|
||||
void get_sys_info()
|
||||
void
|
||||
get_sys_info()
|
||||
{
|
||||
long stck;
|
||||
long *jar;
|
||||
OSH *oshdr;
|
||||
|
||||
kparam.cputype = 0;
|
||||
kparam.bootflags = 0;
|
||||
|
||||
stck = Super(0);
|
||||
|
||||
@ -225,18 +234,18 @@ void get_sys_info()
|
||||
*/
|
||||
oshdr = *ADDR_OSHEAD;
|
||||
oshdr = oshdr->os_beg;
|
||||
if((oshdr->os_version >= 0x0300) && (oshdr->os_version < 0x0306))
|
||||
kparam.cputype |= ATARI_CLKBROKEN;
|
||||
if ((oshdr->os_version > 0x0300) && (oshdr->os_version < 0x0306))
|
||||
kparam.bootflags |= ATARI_CLKBROKEN;
|
||||
|
||||
if(kparam.stmem_size <= 0)
|
||||
if (kparam.stmem_size <= 0)
|
||||
kparam.stmem_size = *ADDR_PHYSTOP;
|
||||
|
||||
if(kparam.ttmem_size)
|
||||
if (kparam.ttmem_size)
|
||||
kparam.ttmem_start = TTRAM_BASE;
|
||||
else {
|
||||
if(!s_flag && (*ADDR_CHKRAMTOP == RAM_TOP_MAGIC)) {
|
||||
if (!s_flag && (*ADDR_CHKRAMTOP == RAM_TOP_MAGIC)) {
|
||||
kparam.ttmem_size = *ADDR_RAMTOP;
|
||||
if(kparam.ttmem_size > TTRAM_BASE) {
|
||||
if (kparam.ttmem_size > TTRAM_BASE) {
|
||||
kparam.ttmem_size -= TTRAM_BASE;
|
||||
kparam.ttmem_start = TTRAM_BASE;
|
||||
}
|
||||
@ -248,30 +257,30 @@ void get_sys_info()
|
||||
* Scan cookiejar for cpu types
|
||||
*/
|
||||
jar = *ADDR_P_COOKIE;
|
||||
if(jar != NULL) {
|
||||
if (jar != NULL) {
|
||||
do {
|
||||
if(jar[0] == 0x5f435055) { /* _CPU */
|
||||
switch(jar[1]) {
|
||||
if (jar[0] == 0x5f435055) { /* _CPU */
|
||||
switch (jar[1]) {
|
||||
case 0:
|
||||
kparam.cputype |= ATARI_68000;
|
||||
kparam.bootflags |= ATARI_68000;
|
||||
break;
|
||||
case 10:
|
||||
kparam.cputype |= ATARI_68010;
|
||||
kparam.bootflags |= ATARI_68010;
|
||||
break;
|
||||
case 20:
|
||||
kparam.cputype |= ATARI_68020;
|
||||
kparam.bootflags |= ATARI_68020;
|
||||
break;
|
||||
case 30:
|
||||
kparam.cputype |= ATARI_68030;
|
||||
kparam.bootflags |= ATARI_68030;
|
||||
break;
|
||||
case 40:
|
||||
kparam.cputype |= ATARI_68040;
|
||||
kparam.bootflags |= ATARI_68040;
|
||||
break;
|
||||
default:
|
||||
error("Unknown CPU-type");
|
||||
fatal(-1, "Unknown CPU-type");
|
||||
}
|
||||
}
|
||||
if(jar[0] == 0x42504658) { /* BPFX */
|
||||
if (jar[0] == 0x42504658) { /* BPFX */
|
||||
unsigned long *p;
|
||||
|
||||
p = (unsigned long*)jar[1];
|
||||
@ -280,159 +289,65 @@ void get_sys_info()
|
||||
kparam.ttmem_size = p[2];
|
||||
}
|
||||
jar = &jar[2];
|
||||
} while(jar[-2]);
|
||||
} while (jar[-2]);
|
||||
}
|
||||
if(!(kparam.cputype & ATARI_ANYCPU))
|
||||
error("Cannot determine CPU-type");
|
||||
if (!(kparam.bootflags & ATARI_ANYCPU))
|
||||
fatal(-1, "Cannot determine CPU-type");
|
||||
|
||||
Super(stck);
|
||||
(void)Super(stck);
|
||||
|
||||
if(d_flag) {
|
||||
fprintf(stdout, "Machine info:\r\n");
|
||||
fprintf(stdout, "ST-RAM size\t: %10d bytes\r\n", kparam.stmem_size);
|
||||
fprintf(stdout, "TT-RAM size\t: %10d bytes\r\n", kparam.ttmem_size);
|
||||
fprintf(stdout, "TT-RAM start\t: 0x%08x\r\n", kparam.ttmem_start);
|
||||
fprintf(stdout, "Cpu-type\t: 0x%08x\r\n", kparam.cputype);
|
||||
if (d_flag) {
|
||||
eprintf("Machine info:\r\n");
|
||||
eprintf("ST-RAM size\t: %10d bytes\r\n",kparam.stmem_size);
|
||||
eprintf("TT-RAM size\t: %10d bytes\r\n",kparam.ttmem_size);
|
||||
eprintf("TT-RAM start\t: 0x%08x\r\n", kparam.ttmem_start);
|
||||
eprintf("Cpu-type\t: 0x%08x\r\n", kparam.bootflags);
|
||||
}
|
||||
}
|
||||
|
||||
void error(char *fmt, ...)
|
||||
void
|
||||
help()
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
fprintf(stdout, "%s: ", Progname);
|
||||
vfprintf(stdout, fmt, ap);
|
||||
fprintf(stdout, "\r\n");
|
||||
do_exit(1);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
void help()
|
||||
{
|
||||
fprintf(stdout, "\r
|
||||
eprintf("\r
|
||||
NetBSD loader for the Atari-TT\r
|
||||
\r
|
||||
Usage: %s [-abdhstvD] [-S <stram-size>] [kernel]\r
|
||||
Usage: %s [-abdhstVD] [-S <stram-size>] [-T <ttram-size>] [kernel]\r
|
||||
\r
|
||||
Description of options:\r
|
||||
\r
|
||||
\t-a Boot up to multi-user mode.\r
|
||||
\t-b Ask for root device to use.\r
|
||||
\t-d Enter kernel debugger.\r
|
||||
\t-D printout debug information while loading\r
|
||||
\t-h What your getting right now.\r
|
||||
\t-o Write output to both <output file> and stdout.\r
|
||||
\t-s Use only ST-compatible RAM\r
|
||||
\t-S Set amount of ST-compatible RAM\r
|
||||
\t-T Set amount of TT-compatible RAM\r
|
||||
\t-t Test the loader. It will do everything except executing the\r
|
||||
\t loaded kernel.\r
|
||||
\t-D printout debugging information while loading\r
|
||||
\t-v Print loader version.\r
|
||||
\t-V Print loader version.\r
|
||||
\t-w Wait for a keypress before exiting.\r
|
||||
", Progname);
|
||||
do_exit(0);
|
||||
xexit(0);
|
||||
}
|
||||
|
||||
void usage()
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stdout, "Usage: %s [-abdhtv] [kernel]\r\n", Progname);
|
||||
do_exit(1);
|
||||
eprintf("Usage: %s [-abdhstVD] [-S <stram-size>] "
|
||||
"[-T <ttram-size>] [kernel]\r\n", Progname);
|
||||
xexit(1);
|
||||
}
|
||||
|
||||
void do_exit(code)
|
||||
int code;
|
||||
{
|
||||
fprintf(stdout, "\r\nHit <return> to continue...");
|
||||
(void)getchar();
|
||||
fprintf(stdout, "\r\n");
|
||||
exit(code);
|
||||
}
|
||||
|
||||
void start_kernel()
|
||||
void
|
||||
start_kernel()
|
||||
{
|
||||
long stck;
|
||||
|
||||
stck = Super(0);
|
||||
startit();
|
||||
bsd_startup(&kparam);
|
||||
/* NOT REACHED */
|
||||
|
||||
Super(stck);
|
||||
(void)Super(stck);
|
||||
}
|
||||
|
||||
asm("
|
||||
.text
|
||||
.globl _startit
|
||||
|
||||
_startit:
|
||||
move.w #0x2700,sr
|
||||
|
||||
| the BSD kernel wants values into the following registers:
|
||||
| d0: ttmem-size
|
||||
| d1: stmem-size
|
||||
| d2: cputype
|
||||
| d3: boothowto
|
||||
| d4: length of loaded kernel
|
||||
| d5: start of fastram
|
||||
| a0: start of loaded kernel
|
||||
| a1: end of symbols (esym)
|
||||
| All other registers zeroed for possible future requirements.
|
||||
|
||||
lea _kparam, a3 | a3 points to parameter block
|
||||
lea _startit,sp | make sure we have a good stack ***
|
||||
move.l (a3),a0 | loaded kernel
|
||||
move.l 8(a3),-(sp) | push entry point ***
|
||||
move.l a0,d0 | offset of loaded kernel
|
||||
add.l d0,(sp) | add offset
|
||||
move.l 12(a3),d1 | stmem-size
|
||||
move.l 16(a3),d0 | ttmem-size
|
||||
move.l 20(a3),d2 | cputype
|
||||
move.l 24(a3),d3 | boothowto
|
||||
move.l 4(a3),d4 | length of loaded kernel
|
||||
move.l 28(a3),d5 | start of fastram
|
||||
move.l 32(a3),a1 | end of symbols
|
||||
sub.l a5,a5 | target, load to 0
|
||||
btst #4, d2 | Is this an 68040?
|
||||
beq not040
|
||||
|
||||
| Turn off 68040 MMU
|
||||
.word 0x4e7b,0xd003 | movec a5,tc
|
||||
.word 0x4e7b,0xd806 | movec a5,urp
|
||||
.word 0x4e7b,0xd807 | movec a5,srp
|
||||
.word 0x4e7b,0xd004 | movec a5,itt0
|
||||
.word 0x4e7b,0xd005 | movec a5,itt1
|
||||
.word 0x4e7b,0xd006 | movec a5,dtt0
|
||||
.word 0x4e7b,0xd007 | movec a5,dtt1
|
||||
bra nott
|
||||
|
||||
not040:
|
||||
lea zero,a3
|
||||
pmove (a3),tcr | Turn off MMU
|
||||
lea nullrp,a3
|
||||
pmove (a3),crp | Turn off MMU some more
|
||||
pmove (a3),srp | Really, really, turn off MMU
|
||||
|
||||
| Turn off 68030 TT registers
|
||||
btst #3, d2 | Is this an 68030?
|
||||
beq.b nott
|
||||
lea zero,a3
|
||||
pmove (a3),tt0
|
||||
pmove (a3),tt1
|
||||
|
||||
nott:
|
||||
moveq.l #0,d6 | would have known contents)
|
||||
moveq.l #0,d7
|
||||
movea.l d6,a2
|
||||
movea.l d6,a3
|
||||
movea.l d6,a4
|
||||
movea.l d6,a5
|
||||
movea.l d6,a6
|
||||
rts | enter kernel at address on stack ***
|
||||
|
||||
|
||||
| A do-nothing MMU root pointer (includes the following long as well)
|
||||
|
||||
nullrp: .long 0x80000202
|
||||
zero: .long 0
|
||||
svsp: .long 0
|
||||
|
||||
");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: loader.h,v 1.5 1995/08/29 20:35:16 leo Exp $ */
|
||||
/* $NetBSD: loader.h,v 1.6 1996/01/07 22:06:18 leo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 L. Weppelman
|
||||
@ -42,6 +42,10 @@
|
||||
|
||||
#define __LDPGSZ (8*1024) /* Page size for NetBSD */
|
||||
|
||||
#ifndef N_MAGIC
|
||||
#define N_MAGIC(hdr) (hdr.a_magic & 0xffff)
|
||||
#endif
|
||||
|
||||
#define TTRAM_BASE 0x1000000 /* Fastram always starts here */
|
||||
|
||||
/*
|
||||
@ -55,29 +59,6 @@
|
||||
|
||||
#define RAM_TOP_MAGIC (0x1357bd13) /* Magic nr. for ADDR_CHKRAMTOP */
|
||||
|
||||
/*
|
||||
* These should match with the values NetBSD uses!
|
||||
*/
|
||||
#define ATARI_68000 1 /* 68000 CPU */
|
||||
#define ATARI_68010 (1<<1) /* 68010 CPU */
|
||||
#define ATARI_68020 (1<<2) /* 68020 CPU */
|
||||
#define ATARI_68030 (1<<3) /* 68030 CPU */
|
||||
#define ATARI_68040 (1<<4) /* 68040 CPU */
|
||||
#define ATARI_TT (1L<<11) /* This is a TT030 */
|
||||
#define ATARI_FALCON (1L<<12) /* This is a Falcon */
|
||||
|
||||
#define ATARI_CLKBROKEN (1<<16) /* GEMDOS has faulty year base */
|
||||
|
||||
#define ATARI_ANYCPU (0x1f)
|
||||
|
||||
/*
|
||||
* Definitions for boothowto
|
||||
*/
|
||||
#define RB_AUTOBOOT 0x00
|
||||
#define RB_ASKNAME 0x01
|
||||
#define RB_SINGLE 0x02
|
||||
#define RB_KDB 0x40
|
||||
|
||||
/*
|
||||
* Sufficient but incomplete definition os Os-header
|
||||
*/
|
||||
|
11
sys/arch/atari/stand/tostools/rawwrite/Makefile
Normal file
11
sys/arch/atari/stand/tostools/rawwrite/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
# $NetBSD: Makefile,v 1.1 1996/01/07 22:06:22 leo Exp $
|
||||
|
||||
PROG = rawwrite.ttp
|
||||
|
||||
OBJS = rawwrite.o
|
||||
HEADERS =
|
||||
|
||||
include ../Makefile.inc
|
||||
|
||||
${PROG}: ${OBJS} ${LDADD}
|
||||
${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} ${LIBS}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rawwrite.c,v 1.1.1.1 1996/01/07 20:57:03 leo Exp $ */
|
||||
/* $NetBSD: rawwrite.c,v 1.2 1996/01/07 22:06:24 leo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Leo Weppelman.
|
||||
@ -31,22 +31,31 @@
|
||||
*/
|
||||
|
||||
#include <osbind.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include "libtos.h"
|
||||
|
||||
#define SECT_SIZE 512 /* Sector size */
|
||||
#define NSECT_DD 18 /* Sectors per track 720Kb */
|
||||
#define NSECT_HD 36 /* Sectors per track 1.44Mb */
|
||||
#define NTRK 80 /* Number of tracks */
|
||||
|
||||
static void usage();
|
||||
static void brwrite();
|
||||
static void help PROTO((void));
|
||||
static void usage PROTO((void));
|
||||
static void brwrite PROTO((char *, int));
|
||||
|
||||
char buf[NSECT_HD * SECT_SIZE];
|
||||
int vflag = 0;
|
||||
int h_flag = 0; /* Show help */
|
||||
int v_flag = 0; /* Verbose (a dot for each track copied) */
|
||||
int V_flag = 0; /* Show version */
|
||||
char *progname;
|
||||
|
||||
const char version[] = "$Revision: 1.2 $";
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
@ -60,56 +69,99 @@ char *argv[];
|
||||
int nsect;
|
||||
|
||||
progname = argv[0];
|
||||
while ((ch = getopt(argc, argv, "v")) != EOF) {
|
||||
switch(ch) {
|
||||
init_toslib(argv[0]);
|
||||
|
||||
while ((ch = getopt(argc, argv, "hvVwo:")) != EOF) {
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
h_flag = 1;
|
||||
break;
|
||||
case 'o':
|
||||
redirect_output(optarg);
|
||||
break;
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
v_flag = 1;
|
||||
break;
|
||||
case 'V':
|
||||
V_flag = 1;
|
||||
break;
|
||||
case 'w':
|
||||
set_wait_for_key();
|
||||
break;
|
||||
default :
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(optind >= argc)
|
||||
if (h_flag)
|
||||
help();
|
||||
if (V_flag)
|
||||
eprintf("%s\r\n", version);
|
||||
|
||||
if (optind >= argc)
|
||||
usage();
|
||||
|
||||
infile = argv[optind];
|
||||
nsect = NSECT_DD;
|
||||
|
||||
if((fd = open(infile, O_RDONLY)) < 0) {
|
||||
fprintf(stderr, "%s: Cannot open '%s'\n", progname, infile);
|
||||
exit(1);
|
||||
}
|
||||
if ((fd = open(infile, O_RDONLY)) < 0)
|
||||
fatal(-1, "Cannot open '%s'\n", infile);
|
||||
|
||||
for(i = 0; i < NTRK; i++) {
|
||||
if(read(fd, buf, nsect * SECT_SIZE) != (nsect * SECT_SIZE)) {
|
||||
fprintf(stderr, "\nRead error on '%s'\n", progname, infile);
|
||||
exit(1);
|
||||
for (i = 0; i < NTRK; i++) {
|
||||
if (read(fd, buf, nsect * SECT_SIZE) != (nsect * SECT_SIZE))
|
||||
fatal(-1, "\n\rRead error on '%s'\n", infile);
|
||||
if (v_flag) {
|
||||
if (i && !(i % 40))
|
||||
eprintf("\r\n");
|
||||
eprintf(".");
|
||||
}
|
||||
if(vflag) {
|
||||
if(i && !(i % 40))
|
||||
printf("\n");
|
||||
fprintf(stderr, ".");
|
||||
}
|
||||
brwrite(buf, nsect * i, nsect);
|
||||
brwrite(buf, i);
|
||||
}
|
||||
close(fd);
|
||||
if(vflag)
|
||||
printf("\n");
|
||||
if (v_flag)
|
||||
eprintf("\r\n");
|
||||
xexit(0);
|
||||
}
|
||||
|
||||
static void brwrite(buf, blk, cnt)
|
||||
static void
|
||||
brwrite(buf, trk)
|
||||
char *buf;
|
||||
int blk, cnt;
|
||||
int trk;
|
||||
{
|
||||
if(Rwabs(3, buf, cnt, blk, 0) != 0) {
|
||||
fprintf(stderr, "\n%s: Write error on floppy\n", progname);
|
||||
exit(1);
|
||||
static u_char trbuf[NSECT_DD * SECT_SIZE * 2];
|
||||
static u_int sideno = 0;
|
||||
|
||||
for (sideno = 0; sideno < 2; sideno++) {
|
||||
if (Flopfmt(trbuf, 0, 0, NSECT_DD/2, trk, sideno, 1, 0x87654321,
|
||||
0xe5e5))
|
||||
fatal(-1, "Format error");
|
||||
if (Flopwr(buf, 0, 0, 1, trk, sideno, NSECT_DD/2))
|
||||
fatal(-1, "Write error");
|
||||
buf += (NSECT_DD/2) * SECT_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
static void usage()
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "usage: rawwrite [-v] <infile>\n");
|
||||
exit(1);
|
||||
eprintf("Usage: %s [-hvVw] [-o <log-file>] <infile>\r\n", progname);
|
||||
xexit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
help()
|
||||
{
|
||||
eprintf("\r
|
||||
write a raw floppy-image to disk\r
|
||||
\r
|
||||
Usage: %s [-hvVw] [-o <log-file>] <infile>\r
|
||||
\r
|
||||
Description of options:\r
|
||||
\r
|
||||
\t-h What your getting right now.\r
|
||||
\t-o Write output to both <output file> and stdout.\r
|
||||
\t-v Show a '.' for each track written.\r
|
||||
\t-V Print program version.\r
|
||||
\t-w Wait for a keypress before exiting.\r
|
||||
", progname);
|
||||
xexit(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user