From 48761aa7b42e6c9eb6d41f1ab19386718e1d88f3 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 10 Oct 2018 22:17:26 +0100 Subject: [PATCH] util: build new tools --- Applications/util/Makefile.6502 | 2 + Applications/util/Makefile.6809 | 2 + Applications/util/Makefile.z80 | 2 + Applications/util/chmem.8 | 30 +++++++++++++ Applications/util/labelfs.8 | 26 ++++++++++++ Applications/util/mkfs.8 | 25 +++++++++++ Applications/util/size.1 | 12 ++++++ Applications/util/size.c | 74 +++++++++++++++++++++++++++++++++ 8 files changed, 173 insertions(+) create mode 100644 Applications/util/chmem.8 create mode 100644 Applications/util/labelfs.8 create mode 100644 Applications/util/mkfs.8 create mode 100644 Applications/util/size.1 create mode 100644 Applications/util/size.c diff --git a/Applications/util/Makefile.6502 b/Applications/util/Makefile.6502 index 82116103..280700b9 100644 --- a/Applications/util/Makefile.6502 +++ b/Applications/util/Makefile.6502 @@ -55,6 +55,7 @@ SRCSNS = \ SRCS = banner.c \ bd.c \ cal.c \ + chmem.c \ cksum.c \ cut.c \ dd.c \ @@ -90,6 +91,7 @@ SRCS = banner.c \ sed.c \ seq.c \ setdate.c \ + size.c \ sleep.c \ ssh.c \ sort.c \ diff --git a/Applications/util/Makefile.6809 b/Applications/util/Makefile.6809 index 092d509c..f1d69583 100644 --- a/Applications/util/Makefile.6809 +++ b/Applications/util/Makefile.6809 @@ -61,6 +61,7 @@ SRCS = \ bd.c \ bogomips.c \ cal.c \ + chmem.c \ cksum.c \ cut.c \ dd.c \ @@ -98,6 +99,7 @@ SRCS = \ sed.c \ seq.c \ setdate.c \ + size.c \ sleep.c \ ssh.c \ socktest.c \ diff --git a/Applications/util/Makefile.z80 b/Applications/util/Makefile.z80 index cd89a87c..357b7534 100644 --- a/Applications/util/Makefile.z80 +++ b/Applications/util/Makefile.z80 @@ -49,6 +49,7 @@ SRCS = banner.c \ bd.c \ bogomips.c \ cal.c \ + chmem.c \ cksum.c \ cpuinfo.c \ cut.c \ @@ -88,6 +89,7 @@ SRCS = banner.c \ remount.c \ seq.c \ setdate.c \ + size.c \ sleep.c \ ssh.c \ sort.c \ diff --git a/Applications/util/chmem.8 b/Applications/util/chmem.8 new file mode 100644 index 00000000..635aec03 --- /dev/null +++ b/Applications/util/chmem.8 @@ -0,0 +1,30 @@ +CHMEM(8) +## NAME +*chmem* - change memory allocation for a binary +## SYNOPSIS +*chmem* \[size\] path + +## DESCRIPTION +*Chmem* shows and updates the header field in a Fuzix binary that indicates +the largest amount of dynamic memory and stack required. The zero value means +unlimited. The application is not guaranteed to get that much memory, it is +instead a promise by the application not to use any more. + +When *size* is specified the binary is updated for that size in bytes. When +no size is specified the current setting is displayed. + +## SEE ALSO ## +*size*(1) + +## BUGS ## +It would be far more useful to be able to specify the amount of stack +required. +Only certain memory manager support this field, others will always allocate +as it was zero. This makes testing chmem settings difficult. + +## FUTURE ## +This interface will be obsoleted in favour of a stack size setting in some future +release. + +## STANDARDS ## +Fuzix specific. Minix has a similar chmem feature. diff --git a/Applications/util/labelfs.8 b/Applications/util/labelfs.8 new file mode 100644 index 00000000..5c8d6865 --- /dev/null +++ b/Applications/util/labelfs.8 @@ -0,0 +1,26 @@ +LABELFS(8) +## NAME +*labelfs* - label a file system with a name or geometry +## SYNPOSIS +*labelfs* \[-l label\] \[-g heads,cyls,secs\[,blocksize\[,skew\]\]\] path + +## DESCRIPTION +The *labelfs* utility allows the display or modification of geometry and +label data applied to a file system. It is primarily intended to be used +with floppy disk media. + +When no label or geometry option is given the program will display the +current label and geometry if present. + +When the options are provided the values are written into the media. The +sector size must be a power of two and at least 128 bytes. Labels are an +arbitrar text string of up to 32 bytes. + +## BUGS +None known + +## STANDARDS +Fuzix specific. + +## AUTHOR +Alan Cox diff --git a/Applications/util/mkfs.8 b/Applications/util/mkfs.8 new file mode 100644 index 00000000..b3f984c0 --- /dev/null +++ b/Applications/util/mkfs.8 @@ -0,0 +1,25 @@ +MKFS(8) +## NAME +*mkfs* \[-f\] device isize fsize + +## DESCRIPTION +The *mkfs* tool initializes a new file system on a device. + +The isize field specifies the number of inode blocks on the file system. +Each inode block holds 8 inodes. This determines the number of individual +files and directories that may be present on the disk. + +The fsize field gives the size of the media in 512 byte blocks - up to 65535 +blocks for 32MB media. + +The default behaviour is to zero the entire file system and then write the +new metadata to the device. If the -f flag is passed then the data areas are +not cleared, bad data blocks may not be found and old data may persist in +blocks not allocated to files. + +## BUGS +None know + +## STANDARDS +Whilst most Fuzix-like systems have a mkfs command the syntax, functionality +and file system format varies extensively. diff --git a/Applications/util/size.1 b/Applications/util/size.1 new file mode 100644 index 00000000..2418a167 --- /dev/null +++ b/Applications/util/size.1 @@ -0,0 +1,12 @@ +SIZE(1) +## NAME +*size* path... - display the size of a binary +## DESCRIPTION +The *size* command displays the amount of memory required by an application +for the text, data, and BSS (base stack segment - zeroed data), as well as +the total size. This does not include stack and any dynamic space required +to execute it. +## SEE ALSO +*chmem*(8) +## AUTHOR +Written by Alan Cox diff --git a/Applications/util/size.c b/Applications/util/size.c new file mode 100644 index 00000000..bf28dd3e --- /dev/null +++ b/Applications/util/size.c @@ -0,0 +1,74 @@ +#include +#include +#include +#include + +static unsigned int +bufpair(int bigend, unsigned char *p, int n) +{ + if (bigend) { + /* mc6809, big endian */ + return (p[n] << 8) | p[n+1]; + } + return p[n] | (p[n+1] << 8); +} + +int main(int argc, char *argv[]) +{ + FILE *fp; + unsigned char buf[16]; + unsigned int basepage; + int n, endian; + unsigned int txtsz, datsz, bsssz; + + if (argc < 2) { + fprintf(stderr, "%s [executable]\n", argv[0]); + exit(1); + } + for (n = 1; n < argc; n++) { + fp = fopen(argv[n], "r"); + if (fp == NULL) { + perror(argv[n]); + exit(1); + } + if (fread(buf, 16, 1, fp) != 1) { + fprintf(stderr, "%s: too short ?\n", argv[0]); + exit(1); + } + + basepage = 0; + if (buf[0] == 0xC3 || buf[0] == 0x18 || buf[0] == 0x4C || buf[0] == 0x38) { + /* Z-80 or 6502 */ + endian = 0; + basepage = buf[7] << 8; + } else if (buf[0] == 0x7E || buf[0] == 0x20) { + /* 6809 */ + endian = 1; + } else { + endian = -1; + } + if ((endian == -1) || + (buf[3] != 'F') || + (buf[4] != 'Z') || + (buf[5] != 'X') || + (buf[6] != '1')) { + fprintf(stderr, "%s: not a Fuzix binary format.\n", argv[1]); + exit(1); + } + fclose(fp); + printf(" base text data bss size hex filename\n"); + + /* Text, data, BSS */ + txtsz = bufpair(endian, buf, 10); + datsz = bufpair(endian, buf, 12); + bsssz = bufpair(endian, buf, 14); + + printf("%5x%5x%5x%5x%7d%5x %s\n", + basepage, + txtsz, datsz, bsssz, + txtsz+datsz+bsssz, + txtsz+datsz+bsssz, + argv[n]); + } + exit(0); +} -- 2.34.1