Skip to content

Commit

Permalink
Merge pull request #1849 from ghaerr/meminfo2
Browse files Browse the repository at this point in the history
[cmds] Meminfo and ps updates, small fixes
  • Loading branch information
ghaerr authored Apr 6, 2024
2 parents 8c23243 + 410d28b commit abff62a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ static int DFPROC floppy_register(void)
current_DOR = 0x0c;
outb(0x0c, FD_DOR); /* all motors off, enable IRQ and DMA */

floppy_buffer = heap_alloc(BLOCK_SIZE, HEAP_TAG_BUF);
floppy_buffer = heap_alloc(BLOCK_SIZE, HEAP_TAG_DRVR);
if (!floppy_buffer)
return -ENOMEM;
old_floppy_vec = *((__u32 __far *)FLOPPY_VEC);
Expand Down
2 changes: 1 addition & 1 deletion elks/include/linuxmt/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define HEAP_TAG_CLEAR 0x40 /* return cleared memory*/
#define HEAP_TAG_TYPE 0x0F
#define HEAP_TAG_SEG 0x01 /* main memory segment */
#define HEAP_TAG_BUF 0x02 /* DF floppy or driver buffers */
#define HEAP_TAG_DRVR 0x02 /* DF floppy or driver buffers */
#define HEAP_TAG_TTY 0x03 /* open tty in/out queues */
#define HEAP_TAG_TASK 0x04 /* task array */
#define HEAP_TAG_BUFHEAD 0x05 /* buffer heads */
Expand Down
3 changes: 3 additions & 0 deletions elkscmd/debug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ disasm.o: disasm.c
dis.o: dis.c
$(CC) $(CFLAGS) $(NOINSTFLAGS) -c -o $*.o $<

nm86.o: nm86.c
$(CC) $(CFLAGS) $(NOINSTFLAGS) -c -o $*.o $<

nm86: nm86.c syms.c
$(HOSTCC) $(HOSTCFLAGS) -D__far= -o $@ $^

Expand Down
1 change: 1 addition & 0 deletions elkscmd/lib/tiny_vfprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ int vfprintf(FILE *op, const char *fmt, va_list ap)

case 'l': /* long data */
lval = 1;
case 'h': /* short data */
goto fmtnxt;

case 'd': /* Signed decimal */
Expand Down
9 changes: 6 additions & 3 deletions elkscmd/man/man1/meminfo.1
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ Show application memory
Show free memory
.TP 5
.B -t
Show tty memory
Show tty and driver memory
.TP 5
.B -b
Show buffer memory
Show system buffer and pipe memory
.TP 5
.B -s
Show system task, inode and file memory.
.SH DESCRIPTION
.B meminfo
traverses the kernel local heap and displays a line for each in-use or free entry.
Expand Down Expand Up @@ -76,7 +79,7 @@ External (main) memory segment.
TTY
TTY input or output buffer.
.TP 10
BUF
DRVR
Direct Floppy or other driver buffers.
.TP 10
BUFH
Expand Down
21 changes: 13 additions & 8 deletions elkscmd/sys_utils/meminfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

int aflag; /* show application memory*/
int fflag; /* show free memory*/
int tflag; /* show tty memory*/
int tflag; /* show tty and driver memory*/
int bflag; /* show buffer memory*/
int sflag; /* show system memory*/
int allflag; /* show all memory*/

unsigned int ds;
Expand Down Expand Up @@ -96,7 +97,7 @@ void dump_heap(int fd)
word_t total_free = 0;
long total_segsize = 0;
static char *heaptype[] =
{ "free", "SEG ", "BUF ", "TTY ", "TASK", "BUFH", "PIPE", "INOD", "FILE" };
{ "free", "SEG ", "DRVR", "TTY ", "TASK", "BUFH", "PIPE", "INOD", "FILE" };
static char *segtype[] =
{ "free", "CSEG", "DSEG", "BUF ", "RDSK", "PROG" };

Expand All @@ -112,7 +113,7 @@ void dump_heap(int fd)
segext_t segsize;
word_t segflags;
byte_t ref_count;
int free, used, tty, buffer;
int free, used, tty, buffer, system;
struct task_struct *t;

if (tag == HEAP_TAG_SEG)
Expand All @@ -122,13 +123,14 @@ void dump_heap(int fd)
used = ((tag == HEAP_TAG_SEG)
&& (segflags == SEG_FLAG_CSEG || segflags == SEG_FLAG_DSEG
|| segflags == SEG_FLAG_PROG));
tty = (tag == HEAP_TAG_TTY);
tty = (tag == HEAP_TAG_TTY || tag == HEAP_TAG_DRVR);
buffer = (tag == HEAP_TAG_SEG && segflags == SEG_FLAG_EXTBUF)
|| (tag == HEAP_TAG_BUFHEAD) || (tag == HEAP_TAG_BUF)
|| (tag == HEAP_TAG_PIPE);
|| tag == HEAP_TAG_BUFHEAD || tag == HEAP_TAG_PIPE;
system = (tag == HEAP_TAG_TASK || tag == HEAP_TAG_INODE || tag == HEAP_TAG_FILE);

if (allflag ||
(fflag && free) || (aflag && used) || (tflag && tty) || (bflag && buffer)) {
(fflag && free) || (aflag && used) || (tflag && tty) || (bflag && buffer)
|| (sflag && system)) {
printf(" %4x %s %5d", mem, heaptype[tag], size);
total_size += size + sizeof(heap_s);
if (tag == HEAP_TAG_FREE)
Expand Down Expand Up @@ -172,7 +174,7 @@ int main(int argc, char **argv)

if (argc < 2)
allflag = 1;
else while ((c = getopt(argc, argv, "aftbh")) != -1) {
else while ((c = getopt(argc, argv, "aftbsh")) != -1) {
switch (c) {
case 'a':
aflag = 1;
Expand All @@ -186,6 +188,9 @@ int main(int argc, char **argv)
case 'b':
bflag = 1;
break;
case 's':
sflag = 1;
break;
case 'h':
usage();
return 0;
Expand Down
8 changes: 6 additions & 2 deletions elkscmd/sys_utils/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ int main(int argc, char **argv)
word_t cseg, dseg;
struct passwd * pwent;
int f_listall = 0;
char *progname = argv[0];
int f_uptime = !strcmp(basename(progname), "uptime");
char *progname;
int f_uptime;
struct task_struct task_table;

if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
else progname = argv[0];
f_uptime = !strcmp(progname, "uptime");
while ((c = getopt(argc, argv, "lu")) != -1) {
switch (c) {
case 'l': /* list all - CSEG/DSEG */
Expand Down

0 comments on commit abff62a

Please sign in to comment.