From fdd653d9691840306fce5d984e9f5ccde6926e91 Mon Sep 17 00:00:00 2001 From: Rafael Zurita Date: Mon, 1 Jun 2020 10:20:38 -0300 Subject: [PATCH] from bbb port --- include/name.h | 5 +- include/orig/name.h | 19 ++ include/orig/ports.h | 29 ++ include/orig/process.h | 62 ++++ include/orig/prototypes.h | 619 ++++++++++++++++++++++++++++++++++++++ include/orig/shell.h | 75 +++++ include/orig/stdio.h | 34 +++ include/orig/tty.h | 84 ++++++ include/ports.h | 4 +- include/process.h | 9 +- include/prototypes.h | 9 +- include/queue.h | 7 - include/ramdisk.h | 4 +- 13 files changed, 932 insertions(+), 28 deletions(-) create mode 100644 include/orig/name.h create mode 100644 include/orig/ports.h create mode 100644 include/orig/process.h create mode 100644 include/orig/prototypes.h create mode 100644 include/orig/shell.h create mode 100644 include/orig/stdio.h create mode 100644 include/orig/tty.h diff --git a/include/name.h b/include/name.h index 75af45f..4caf1de 100644 --- a/include/name.h +++ b/include/name.h @@ -1,13 +1,12 @@ /* name.h */ +/* avr specific values. Original saved under orig/ folder */ + /* Constants that define the namespace mapping table sizes */ -// RAFA #define NM_PRELEN 64 /* Max size of a prefix string */ #define NM_PRELEN 8 /* Max size of a prefix string */ -// RAFA #define NM_REPLLEN 96 /* Maximum size of a replacement*/ #define NM_REPLLEN 8 /* Maximum size of a replacement*/ #define NM_MAXLEN 8 /* Maximum size of a file name */ -// RAFA #define NNAMES 40 /* Number of prefix definitions */ #define NNAMES 3 /* Number of prefix definitions */ /* Definition of the name prefix table that defines all name mappings */ diff --git a/include/orig/name.h b/include/orig/name.h new file mode 100644 index 0000000..6dc9e38 --- /dev/null +++ b/include/orig/name.h @@ -0,0 +1,19 @@ +/* name.h */ + +/* Constants that define the namespace mapping table sizes */ + +#define NM_PRELEN 64 /* Max size of a prefix string */ +#define NM_REPLLEN 96 /* Maximum size of a replacement*/ +#define NM_MAXLEN 256 /* Maximum size of a file name */ +#define NNAMES 40 /* Number of prefix definitions */ + +/* Definition of the name prefix table that defines all name mappings */ + +struct nmentry { /* Definition of prefix table */ + char nprefix[NM_PRELEN]; /* Null-terminated prefix */ + char nreplace[NM_REPLLEN]; /* Null-terminated replacement */ + did32 ndevice; /* Device descriptor for prefix */ +}; + +extern struct nmentry nametab[]; /* Table of name mappings */ +extern int32 nnames; /* Number of entries allocated */ diff --git a/include/orig/ports.h b/include/orig/ports.h new file mode 100644 index 0000000..52848d7 --- /dev/null +++ b/include/orig/ports.h @@ -0,0 +1,29 @@ +/* ports.h - isbadport */ + +#define NPORTS 30 /* Maximum number of ports */ +#define PT_MSGS 100 /* Total messages in system */ +#define PT_FREE 1 /* Port is free */ +#define PT_LIMBO 2 /* Port is being deleted/reset */ +#define PT_ALLOC 3 /* Port is allocated */ + +struct ptnode { /* Node on list of messages */ + uint32 ptmsg; /* A one-word message */ + struct ptnode *ptnext; /* Pointer to next node on list */ +}; + +struct ptentry { /* Entry in the port table */ + sid32 ptssem; /* Sender semaphore */ + sid32 ptrsem; /* Receiver semaphore */ + uint16 ptstate; /* Port state (FREE/LIMBO/ALLOC)*/ + uint16 ptmaxcnt; /* Max messages to be queued */ + int32 ptseq; /* Sequence changed at creation */ + struct ptnode *pthead; /* List of message pointers */ + struct ptnode *pttail; /* Tail of message list */ +}; + +extern struct ptnode *ptfree; /* List of free nodes */ +extern struct ptentry porttab[]; /* Port table */ +extern int32 ptnextid; /* Next port ID to try when */ + /* looking for a free slot */ + +#define isbadport(portid) ( (portid)<0 || (portid)>=NPORTS ) diff --git a/include/orig/process.h b/include/orig/process.h new file mode 100644 index 0000000..09a5b00 --- /dev/null +++ b/include/orig/process.h @@ -0,0 +1,62 @@ +/* process.h - isbadpid */ + +/* Maximum number of processes in the system */ + +#ifndef NPROC +#define NPROC 8 +#endif + +/* Process state constants */ + +#define PR_FREE 0 /* Process table entry is unused */ +#define PR_CURR 1 /* Process is currently running */ +#define PR_READY 2 /* Process is on ready queue */ +#define PR_RECV 3 /* Process waiting for message */ +#define PR_SLEEP 4 /* Process is sleeping */ +#define PR_SUSP 5 /* Process is suspended */ +#define PR_WAIT 6 /* Process is on semaphore queue */ +#define PR_RECTIM 7 /* Process is receiving with timeout */ + +/* Miscellaneous process definitions */ + +#define PNMLEN 16 /* Length of process "name" */ +#define NULLPROC 0 /* ID of the null process */ + +/* Process initialization constants */ + +#define INITSTK 65536 /* Initial process stack size */ +#define INITPRIO 20 /* Initial process priority */ +#define INITRET userret /* Address to which process returns */ + +/* Inline code to check process ID (assumes interrupts are disabled) */ + +#define isbadpid(x) ( ((pid32)(x) < 0) || \ + ((pid32)(x) >= NPROC) || \ + (proctab[(x)].prstate == PR_FREE)) + +/* Number of device descriptors a process can have open */ + +#define NDESC 5 /* must be odd to make procent 4N bytes */ + +/* Definition of the process table (multiple of 32 bits) */ + +struct procent { /* Entry in the process table */ + uint16 prstate; /* Process state: PR_CURR, etc. */ + pri16 prprio; /* Process priority */ + char *prstkptr; /* Saved stack pointer */ + char *prstkbase; /* Base of run time stack */ + uint32 prstklen; /* Stack length in bytes */ + char prname[PNMLEN]; /* Process name */ + sid32 prsem; /* Semaphore on which process waits */ + pid32 prparent; /* ID of the creating process */ + umsg32 prmsg; /* Message sent to this process */ + bool8 prhasmsg; /* Nonzero iff msg is valid */ + int16 prdesc[NDESC]; /* Device descriptors for process */ +}; + +/* Marker for the top of a process stack (used to help detect overflow) */ +#define STACKMAGIC 0x0A0AAAA9 + +extern struct procent proctab[]; +extern int32 prcount; /* Currently active processes */ +extern pid32 currpid; /* Currently executing process */ diff --git a/include/orig/prototypes.h b/include/orig/prototypes.h new file mode 100644 index 0000000..809bf0b --- /dev/null +++ b/include/orig/prototypes.h @@ -0,0 +1,619 @@ +/* in file addargs.c */ +extern status addargs(pid32, int32, int32[], int32,char *, void *); + +/* in file am335x_eth_init.c */ +extern int32 am335x_eth_init(struct ethcblk *); + +/* in file arp.c */ +extern void arp_init(void); +extern status arp_resolve(uint32, byte[]); +extern void arp_in(struct arppacket *); +extern int32 arp_alloc(void); +extern void arp_ntoh(struct arppacket *); +extern void arp_hton(struct arppacket *); + +/* in file ascdate.c */ +extern status ascdate(uint32, char *); + +/* in file bufinit.c */ +extern status bufinit(void); + +/* in file chprio.c */ +extern pri16 chprio(pid32, pri16); + +/* in file clkupdate.S */ +extern uint32 clkcount(void); + +/* in file clkhandler.c */ +extern interrupt clkhandler(void); + +/* in file clkinit.c */ +extern void clkinit(void); + +/* in file clkint.S */ +extern void clkint(void); + +/* in file close.c */ +extern syscall close(did32); + +/* in file control.c */ +extern syscall control(did32, int32, int32, int32); + +/* in file create.c */ +extern pid32 create(void *, uint32, pri16, char *, uint32, ...); + +/* in file ctxsw.S */ +extern void ctxsw(void *, void *); + +/* in file dhcp.c */ +extern uint32 getlocalip(void); + +/* in file dns.c */ +extern uint32 dnslookup(char *); + +/* in file dot2ip.c */ +extern uint32 dot2ip(char *, uint32 *); + +/* in file ethcontrol.c */ +extern int32 ethcontrol(struct dentry *, int32, int32, int32); + +/* in file ethinit.c */ +extern int32 ethinit(struct dentry *); + +/* in file ethhandler.c */ +extern interrupt ethhandler(uint32); + +/* in file ethread.c */ +extern int32 ethread(struct dentry *, void *, uint32); + +/* in file ethwrite.c */ +extern int32 ethwrite(struct dentry *, void *, uint32); + +/* in file evec.c */ + +extern int32 initintc(void); +extern int32 initevec(void); +extern int32 set_evec(uint32, uint32); +extern void trap(int32); + +/* in file exception.c */ +extern void exception(int32, int32*); + +/* in file freebuf.c */ +extern syscall freebuf(char *); + +/* in file freemem.c */ +extern syscall freemem(char *, uint32); + +/* in file getbuf.c */ +extern char *getbuf(bpid32); + +/* in file getc.c */ +extern syscall getc(did32); + +/* in file getitem.c */ +extern pid32 getfirst(qid16); +extern pid32 getlast(qid16); +extern pid32 getitem(pid32); + +/* in file getmem.c */ +extern char *getmem(uint32); + +/* in file getpid.c */ +extern pid32 getpid(void); + +/* in file getprio.c */ +extern syscall getprio(pid32); + +/* in file getstk.c */ +extern char *getstk(uint32); + +/* in file getticks.c */ +extern uint32 getticks(void); + +/* in file gettime.c */ +extern status gettime(uint32 *); + +/* in file getutime.c */ +extern status getutime(uint32 *); + +/* in file gpiocontrol.c */ +extern devcall gpiocontrol(struct dentry *, int32, int32, int32); + +/* in file gpiohandler.c */ +extern void gpiohandler(uint32); + +/* in file gpioinit.c */ +extern devcall gpioinit(struct dentry *); + +/* in file gpioselect.c */ +extern devcall gpioselect(uint32, uint32, uint32); + +/* in file gpioread.c */ +extern devcall gpioread(struct dentry *,char *, int32); + +/* in file gpiowrite.c */ +extern devcall gpiowrite(struct dentry *, char *, int32); + +/* in file halt.S */ +extern void halt(void); + +/* in file icmp.c */ + +extern void icmp_init(void); +extern void icmp_in(struct netpacket *); +extern int32 icmp_register(uint32); +extern int32 icmp_recv(int32, char *, int32, uint32); +extern status icmp_send(uint32, uint16, uint16, uint16, char *, int32); +extern struct netpacket *icmp_mkpkt(uint32, uint16, uint16, uint16, char *, int32); +extern status icmp_release(int32); +extern uint16 icmp_cksum(char *, int32); +extern void icmp_hton(struct netpacket *); +extern void icmp_ntoh(struct netpacket *); + +/* in file init.c */ +extern syscall init(did32); + +/* in file insert.c */ +extern status insert(pid32, qid16, int32); + +/* in file insertd.c */ +extern status insertd(pid32, qid16, int32); + +/* in file intr.S */ +extern intmask disable(void); +extern void enable(void); + +/* in file ioerr.c */ +extern devcall ioerr(void); + +/* in file ionull.c */ +extern devcall ionull(void); + +/* in file ip.c */ +extern void ip_in(struct netpacket *); +extern status ip_send(struct netpacket *); +extern void ip_local(struct netpacket *); +extern status ip_out(struct netpacket *); +extern int32 ip_route(uint32); +extern uint16 ipcksum(struct netpacket *); +extern void ip_ntoh(struct netpacket *); +extern void ip_hton(struct netpacket *); +extern process ipout(void); +extern status ip_enqueue(struct netpacket *); + +/* in file net.c */ +extern void net_init(void); +extern process netin(void); +extern process netout(void); +extern process rawin(void); +extern void eth_hton(struct netpacket *); +extern void eth_ntoh(struct netpacket *); +extern uint16 getport(void); + +/* in file kill.c */ +extern syscall kill(pid32); + +/* in file lexan.c */ +extern int32 lexan(char *, int32, char *, int32 *, int32 [], int32 []); + +/* in file lfibclear.c */ +extern void lfibclear(struct lfiblk *, int32); + +/* in file lfibget.c */ +extern void lfibget(did32, ibid32, struct lfiblk *); + +/* in file lfibput.c */ +extern status lfibput(did32, ibid32, struct lfiblk *); + +/* in file lfdbfree.c */ +extern status lfdbfree(did32, dbid32); + +/* in file lfdballoc.c */ +extern dbid32 lfdballoc(struct lfdbfree *); + +/* in file lfflush.c */ +extern status lfflush(struct lflcblk *); + +/* in file lfgetmode.c */ +extern int32 lfgetmode(char *); + +/* in file lfiballoc.c */ +extern ibid32 lfiballoc(void); + +/* in file lflclose.c */ +extern devcall lflclose(struct dentry *); + +/* in file lflcontrol.c */ +extern devcall lflcontrol(struct dentry *, int32, int32, int32); + +/* in file lflgetc.c */ +extern devcall lflgetc(struct dentry *); + +/* in file lflinit.c */ +extern devcall lflinit(struct dentry *); + +/* in file lflputc.c */ +extern devcall lflputc(struct dentry *, char); + +/* in file lflread.c */ +extern devcall lflread(struct dentry *, char *, int32); + +/* in file lflseek.c */ +extern devcall lflseek(struct dentry *, uint32); + +/* in file lflwrite.c */ +extern devcall lflwrite(struct dentry *, char *, int32); + +/* in file lfscheck.c */ +extern status lfscheck(struct lfdir *); + +/* in file lfscreate.c */ +extern status lfscreate(did32, ibid32, uint32); + +/* in file lfsinit.c */ +extern devcall lfsinit(struct dentry *); + +/* in file lfsopen.c */ +extern devcall lfsopen(struct dentry *, char *, char *); + +/* in file lfsetup.c */ +extern status lfsetup(struct lflcblk *); + +/* in file lftruncate.c */ +extern status lftruncate(struct lflcblk *); + +/* in file lpgetc.c */ +extern devcall lpgetc(struct dentry *); + +/* in file lpinit.c */ +extern devcall lpinit(struct dentry *); + +/* in file lpopen.c */ +extern devcall lpopen(struct dentry *, char *, char *); + +/* in file lpputc.c */ +extern devcall lpputc(struct dentry *, char); + +/* in file lpread.c */ +extern devcall lpread(struct dentry *, char *, int32); + +/* in file lpwrite.c */ +extern devcall lpwrite(struct dentry *, char *, int32); + +/* in file mark.c */ +extern void _mkinit(void); + +/* in file memcpy.c */ +extern void *memcpy(void *, const void *, int32); + +/* in file memcpy.c */ +extern int32 *memcmp(void *, const void *, int32); + +/* in file memset.c */ +extern void *memset(void *, const int, int32); + +/* in file mkbufpool.c */ +extern bpid32 mkbufpool(int32, int32); + +/* in file mount.c */ +extern syscall mount(char *, char *, did32); +extern int32 namlen(char *, int32); + +/* in file naminit.c */ +extern status naminit(void); + +/* in file nammap.c */ +extern devcall nammap(char *, char[], did32); +extern did32 namrepl(char *, char[]); +extern status namcpy(char *, char *, int32); + +/* in file namopen.c */ +extern devcall namopen(struct dentry *, char *, char *); + +/* in file newqueue.c */ +extern qid16 newqueue(void); + +/* in file open.c */ +extern syscall open(did32, char *, char *); + +/* in file panic.c */ +extern void panic(char *); + +/* in file pci.c */ +extern int32 pci_init(void); + +/* in file pdump.c */ +extern void pdump(struct netpacket *); +extern void pdumph(struct netpacket *); + +/* in file platinit.c */ +extern void platinit(void); + +/* in file ptclear.c */ +extern void _ptclear(struct ptentry *, uint16, int32 (*)(int32)); + +/* in file ptcount.c */ +extern int32 ptcount(int32); + +/* in file ptcreate.c */ +extern syscall ptcreate(int32); + +/* in file ptdelete.c */ +extern syscall ptdelete(int32, int32 (*)(int32)); + +/* in file ptinit.c */ +extern syscall ptinit(int32); + +/* in file ptrecv.c */ +extern uint32 ptrecv(int32); + +/* in file ptreset.c */ +extern syscall ptreset(int32, int32 (*)(int32)); + +/* in file ptsend.c */ +extern syscall ptsend(int32, umsg32); + +/* in file putc.c */ +extern syscall putc(did32, char); + +/* in file queue.c */ +extern pid32 enqueue(pid32, qid16); +extern pid32 dequeue(qid16); + +/* in file ramclose.c */ +extern devcall ramclose(struct dentry *); + +/* in file raminit.c */ +extern devcall raminit(struct dentry *); + +/* in file ramopen.c */ +extern devcall ramopen(struct dentry *, char *, char *); + +/* in file ramread.c */ +extern devcall ramread(struct dentry *, char *, int32); + +/* in file ramwrite.c */ +extern devcall ramwrite(struct dentry *, char *, int32); + +/* in file rdsclose.c */ +extern devcall rdsclose(struct dentry *); + +/* in file rdscontrol.c */ +extern devcall rdscontrol(struct dentry *, int32, int32, int32); + +/* in file rdsinit.c */ +extern devcall rdsinit(struct dentry *); + +/* in file rdsopen.c */ +extern devcall rdsopen(struct dentry *, char *, char *); + +/* in file rdsread.c */ +extern devcall rdsread(struct dentry *, char *, int32); + +/* in file rdswrite.c */ +extern devcall rdswrite(struct dentry *, char *, int32); + +/* in file rdsbufalloc.c */ +extern struct rdbuff * rdsbufalloc(struct rdscblk *); + +/* in file rdscomm.c */ +extern status rdscomm(struct rd_msg_hdr *, int32, struct rd_msg_hdr *, + int32, struct rdscblk *); + +/* in file rdsprocess.c */ +extern void rdsprocess(struct rdscblk *); + +/* in file read.c */ +extern syscall read(did32, char *, uint32); + +/* in file ready.c */ +extern status ready(pid32); + +/* in file receive.c */ +extern umsg32 receive(void); + +/* in file recvclr.c */ +extern umsg32 recvclr(void); + +/* in file recvtime.c */ +extern umsg32 recvtime(int32); + +/* in file resched.c */ +extern void resched(void); +extern status resched_cntl(int32); + +/* in file intr.S */ +extern void restore(intmask); + +/* in file resume.c */ +extern pri16 resume(pid32); + +/* in file rfsgetmode.c */ +extern int32 rfsgetmode(char * ); + +/* in file rflclose.c */ +extern devcall rflclose(struct dentry *); + +/* in file rfscontrol.c */ +extern devcall rfscontrol(struct dentry *, int32, int32, int32); + +/* in file rflgetc.c */ +extern devcall rflgetc(struct dentry *); + +/* in file rflinit.c */ +extern devcall rflinit(struct dentry *); + +/* in file rflputc.c */ +extern devcall rflputc(struct dentry *, char ); + +/* in file rflread.c */ +extern devcall rflread(struct dentry *, char *, int32 ); + +/* in file rflseek.c */ +extern devcall rflseek(struct dentry *, uint32 ); + +/* in file rflwrite.c */ +extern devcall rflwrite(struct dentry *, char *, int32 ); + +/* in file rfsndmsg.c */ +extern status rfsndmsg(uint16, char *); + +/* in file rfsinit.c */ +extern devcall rfsinit(struct dentry *); + +/* in file rfsopen.c */ +extern devcall rfsopen(struct dentry *devptr, char *, char *); + +/* in file rfscomm.c */ +extern int32 rfscomm(struct rf_msg_hdr *, int32, struct rf_msg_hdr *, int32); + +/* in file rdsclose.c */ +extern devcall rdsclose(struct dentry *); + +/* in file rdscontrol.c */ +extern devcall rdscontrol(struct dentry *, int32, int32, int32); + +/* in file rdsinit.c */ +extern devcall rdsinit(struct dentry *); + +/* in file rdsopen.c */ +extern devcall rdsopen(struct dentry *, char *, char *); + +/* in file rdsread.c */ +extern devcall rdsread(struct dentry *, char *, int32); + +/* in file rdswrite.c */ +extern devcall rdswrite(struct dentry *, char *, int32); + +/* in file rdsbufalloc.c */ +extern struct rdbuff * rdsbufalloc(struct rdscblk *); + +/* in file rdscomm.c */ +extern status rdscomm(struct rd_msg_hdr *, int32, struct rd_msg_hdr *, int32, struct rdscblk *); + +/* in file rdsprocess.c */ +extern void rdsprocess(struct rdscblk *); + +/* in file seek.c */ +extern syscall seek(did32, uint32); + +/* in file semcount.c */ +extern syscall semcount(sid32); + +/* in file semcreate.c */ +extern sid32 semcreate(int32); + +/* in file semdelete.c */ +extern syscall semdelete(sid32); + +/* in file semreset.c */ +extern syscall semreset(sid32, int32); + +/* in file send.c */ +extern syscall send(pid32, umsg32); + +/* in file shell.c */ +extern process shell(did32); + +/* in file signal.c */ +extern syscall signal(sid32); + +/* in file signaln.c */ +extern syscall signaln(sid32, int32); + +/* in file sleep.c */ +extern syscall sleepms(int32); +extern syscall sleep(int32); + +/* in file spicontrol.c */ +extern devcall spicontrol(struct dentry *, int32, int32, int32); + +/* in spiinit.c */ +extern int32 spiinit(struct dentry *); + +/* in file start.S */ +extern int32 inb(int32); +extern int32 inw(int32); +extern int32 inl(int32); +extern int32 outb(int32, int32); +extern int32 outw(int32, int32); +extern int32 outl(int32, int32); +extern int32 outsw(int32, int32, int32); +extern int32 insw(int32, int32 ,int32); + +/* in file suspend.c */ +extern syscall suspend(pid32); + +/* in file ttycontrol.c */ +extern devcall ttycontrol(struct dentry *, int32, int32, int32); + +/* in file ttygetc.c */ +extern devcall ttygetc(struct dentry *); + +/* in file ttyhandle_in.c */ +extern void ttyhandle_in(struct ttycblk *, struct uart_csreg *); + +/* in file ttyhandle_out.c */ +extern void ttyhandle_out(struct ttycblk *, struct uart_csreg *); + +/* in file ttyhandler.c */ +extern void ttyhandler(uint32); + +/* in file ttyinit.c */ +extern devcall ttyinit(struct dentry *); + +/* in file ttykickout.c */ +extern void ttykickout(struct uart_csreg *); + +/* in file ttyputc.c */ +extern devcall ttyputc(struct dentry *, char); + +/* in file ttyread.c */ +extern devcall ttyread(struct dentry *, char *, int32); + +/* in file ttywrite.c */ +extern devcall ttywrite(struct dentry *, char *, int32); + +/* in file udp.c */ + +extern void udp_init(void); +extern void udp_in(struct netpacket *); +extern uid32 udp_register(uint32, uint16, uint16); +extern int32 udp_recv(uid32, char *, int32, uint32); +extern int32 udp_recvaddr(uid32, uint32 *, uint16 *, char *, int32, uint32); +extern status udp_send(uid32, char *, int32); +extern status udp_sendto(uid32, uint32, uint16, char *, int32); +extern status udp_release(uid32); +extern void udp_ntoh(struct netpacket *); +extern void udp_hton(struct netpacket *); + + +/* in file unsleep.c */ +extern syscall unsleep(pid32); + +/* in file userret.c */ +extern void userret(void); + +/* in file wait.c */ +extern syscall wait(sid32); + +/* in file wakeup.c */ +extern void wakeup(void); + +/* in file write.c */ +extern syscall write(did32, char *, uint32); + +/* in file xdone.c */ +extern void xdone(void); + +/* in file yield.c */ +extern syscall yield(void); + +/* NETWORK BYTE ORDER CONVERSION NOT NEEDED ON A BIG-ENDIAN COMPUTER */ +#define htons(x) ( ( 0xff & ((x)>>8) ) | ( (0xff & (x)) << 8 ) ) +#define htonl(x) ( (((x)>>24) & 0x000000ff) | (((x)>> 8) & 0x0000ff00) | \ + (((x)<< 8) & 0x00ff0000) | (((x)<<24) & 0xff000000) ) +#define ntohs(x) ( ( 0xff & ((x)>>8) ) | ( (0xff & (x)) << 8 ) ) +#define ntohl(x) ( (((x)>>24) & 0x000000ff) | (((x)>> 8) & 0x0000ff00) | \ + (((x)<< 8) & 0x00ff0000) | (((x)<<24) & 0xff000000) ) diff --git a/include/orig/shell.h b/include/orig/shell.h new file mode 100644 index 0000000..ffde865 --- /dev/null +++ b/include/orig/shell.h @@ -0,0 +1,75 @@ +/* shell.h - Declarations and constants used by the Xinu shell */ + +/* Size constants */ + +#define SHELL_BUFLEN TY_IBUFLEN+1 /* Length of input buffer */ +#define SHELL_MAXTOK 32 /* Maximum tokens per line */ +#define SHELL_CMDSTK 8192 /* Size of stack for process */ + /* that executes command */ +#define SHELL_ARGLEN (SHELL_BUFLEN+SHELL_MAXTOK) /* Argument area */ +#define SHELL_CMDPRIO 20 /* Process priority for command */ + +/* Message constants */ + +/* Shell banner (assumes VT100) */ + +#define SHELL_BAN0 "\033[31;1m" +#define SHELL_BAN1 "------------------------------------------" +#define SHELL_BAN2 " __ __ _____ _ _ _ _ " +#define SHELL_BAN3 " \\ \\ / / |__ __| | \\ | | | | | | " +#define SHELL_BAN4 " \\ \\/ / | | | \\| | | | | | " +#define SHELL_BAN5 " / /\\ \\ _| |_ | \\ | | | | | " +#define SHELL_BAN6 " / / \\ \\ | | | | \\ | \\ -- / " +#define SHELL_BAN7 " -- -- ----- - - ---- " +#define SHELL_BAN8 "------------------------------------------" +#define SHELL_BAN9 "\033[0m\n" + +/* Messages shell displays for user */ + +#define SHELL_PROMPT "xsh $ " /* Command prompt */ +#define SHELL_STRTMSG "Welcome to Xinu!\n"/* Welcome message */ +#define SHELL_EXITMSG "Shell closed\n"/* Shell exit message */ +#define SHELL_SYNERRMSG "Syntax error\n"/* Syntax error message */ +#define SHELL_CREATMSG "Cannot create process\n"/* command error */ +#define SHELL_INERRMSG "Cannot open file %s for input\n" /* Input err */ +#define SHELL_OUTERRMSG "Cannot open file %s for output\n"/* Output err */ + /* Builtin cmd error message */ +#define SHELL_BGERRMSG "Cannot redirect I/O or background a builtin\n" + +/* Constants used for lexical analysis */ + +#define SH_NEWLINE '\n' /* New line character */ +#define SH_EOF '\04' /* Control-D is EOF */ +#define SH_AMPER '&' /* Ampersand character */ +#define SH_BLANK ' ' /* Blank character */ +#define SH_TAB '\t' /* Tab character */ +#define SH_SQUOTE '\'' /* Single quote character */ +#define SH_DQUOTE '"' /* Double quote character */ +#define SH_LESS '<' /* Less-than character */ +#define SH_GREATER '>' /* Greater-than character */ + +/* Token types */ + +#define SH_TOK_AMPER 0 /* Ampersand token */ +#define SH_TOK_LESS 1 /* Less-than token */ +#define SH_TOK_GREATER 2 /* Greater-than token */ +#define SH_TOK_OTHER 3 /* Token other than those */ + /* listed above (e.g., an */ + /* alphanumeric string) */ + +/* Shell return constants */ + +#define SHELL_OK 0 +#define SHELL_ERROR 1 +#define SHELL_EXIT -3 + +/* Structure of an entry in the table of shell commands */ + +struct cmdent { /* Entry in command table */ + char *cname; /* Name of command */ + bool8 cbuiltin; /* Is this a builtin command? */ + int32 (*cfunc)(int32,char*[]);/* Function for command */ +}; + +extern uint32 ncmd; +extern const struct cmdent cmdtab[]; diff --git a/include/orig/stdio.h b/include/orig/stdio.h new file mode 100644 index 0000000..5f81903 --- /dev/null +++ b/include/orig/stdio.h @@ -0,0 +1,34 @@ +/* stdio.h - definintions and constants for standard I/O functions */ + + +/* Prototypes for formatted input functions */ + +extern int32 _doscan(char *,int32 *, int32 (*)(void), + int32 (*)(char), int32, int32); +extern int32 sscanf(char *, char *, int32); +extern int32 fscanf(int32, char *, int32); +#define scanf(fmt, args) fscanf(CONSOLE, fmt, args) + + +/* Definintion of standard input/ouput/error used with shell commands */ + +#define stdin ((proctab[currpid]).prdesc[0]) +#define stdout ((proctab[currpid]).prdesc[1]) +#define stderr ((proctab[currpid]).prdesc[2]) + + +/* Prototypes for formatted output functions */ + +extern int32 fprintf(int, char *, ...); +extern int32 printf(const char *, ...); +extern int32 sprintf(char *, char *, ...); + + +/* Prototypes for character input and output functions */ + +extern int32 fgetc(int); +extern char *fgets(char *, int32, int32); +extern int32 fputc(int32, int32); +extern int32 fputs(char *, int32); +extern int32 putchar(int32 c); +extern int32 getchar(void); diff --git a/include/orig/tty.h b/include/orig/tty.h new file mode 100644 index 0000000..ff64056 --- /dev/null +++ b/include/orig/tty.h @@ -0,0 +1,84 @@ +/* tty.h */ + +#define TY_OBMINSP 20 /* Min space in buffer before */ + /* processes awakened to write*/ +#define TY_EBUFLEN 20 /* Size of echo queue */ + +/* Size constants */ + +#ifndef Ntty +#define Ntty 1 /* Number of serial tty lines */ +#endif +#ifndef TY_IBUFLEN +#define TY_IBUFLEN 128 /* Num. chars in input queue */ +#endif +#ifndef TY_OBUFLEN +#define TY_OBUFLEN 64 /* Num. chars in output queue */ +#endif + +/* Mode constants for input and output modes */ + +#define TY_IMRAW 'R' /* Raw input mode => no edits */ +#define TY_IMCOOKED 'C' /* Cooked mode => line editing */ +#define TY_IMCBREAK 'K' /* Honor echo, etc, no line edit*/ +#define TY_OMRAW 'R' /* Raw output mode => no edits */ + +struct ttycblk { /* Tty line control block */ + char *tyihead; /* Next input char to read */ + char *tyitail; /* Next slot for arriving char */ + char tyibuff[TY_IBUFLEN]; /* Input buffer (holds one line)*/ + sid32 tyisem; /* Input semaphore */ + char *tyohead; /* Next output char to xmit */ + char *tyotail; /* Next slot for outgoing char */ + char tyobuff[TY_OBUFLEN]; /* Output buffer */ + sid32 tyosem; /* Output semaphore */ + char *tyehead; /* Next echo char to xmit */ + char *tyetail; /* Next slot to deposit echo ch */ + char tyebuff[TY_EBUFLEN]; /* Echo buffer */ + char tyimode; /* Input mode raw/cbreak/cooked */ + bool8 tyiecho; /* Is input echoed? */ + bool8 tyieback; /* Do erasing backspace on echo?*/ + bool8 tyevis; /* Echo control chars as ^X ? */ + bool8 tyecrlf; /* Echo CR-LF for newline? */ + bool8 tyicrlf; /* Map '\r' to '\n' on input? */ + bool8 tyierase; /* Honor erase character? */ + char tyierasec; /* Primary erase character */ + char tyierasec2; /* Alternate erase character */ + bool8 tyeof; /* Honor EOF character? */ + char tyeofch; /* EOF character (usually ^D) */ + bool8 tyikill; /* Honor line kill character? */ + char tyikillc; /* Line kill character */ + int32 tyicursor; /* Current cursor position */ + bool8 tyoflow; /* Honor ostop/ostart? */ + bool8 tyoheld; /* Output currently being held? */ + char tyostop; /* Character that stops output */ + char tyostart; /* Character that starts output */ + bool8 tyocrlf; /* Output CR/LF for LF ? */ + char tyifullc; /* Char to send when input full */ +}; +extern struct ttycblk ttytab[]; + +/* Characters with meaning to the tty driver */ + +#define TY_BACKSP '\b' /* Backspace character */ +#define TY_BACKSP2 '\177' /* Alternate backspace char. */ +#define TY_BELL '\07' /* Character for audible beep */ +#define TY_EOFCH '\04' /* Control-D is EOF on input */ +#define TY_BLANK ' ' /* Blank */ +#define TY_NEWLINE '\n' /* Newline == line feed */ +#define TY_RETURN '\r' /* Carriage return character */ +#define TY_STOPCH '\023' /* Control-S stops output */ +#define TY_STRTCH '\021' /* Control-Q restarts output */ +#define TY_KILLCH '\025' /* Control-U is line kill */ +#define TY_UPARROW '^' /* Used for control chars (^X) */ +#define TY_FULLCH TY_BELL /* Char to echo when buffer full*/ + +/* Tty control function codes */ + +#define TC_NEXTC 3 /* Look ahead 1 character */ +#define TC_MODER 4 /* Set input mode to raw */ +#define TC_MODEC 5 /* Set input mode to cooked */ +#define TC_MODEK 6 /* Set input mode to cbreak */ +#define TC_ICHARS 8 /* Return number of input chars */ +#define TC_ECHO 9 /* Turn on echo */ +#define TC_NOECHO 10 /* Turn off echo */ diff --git a/include/ports.h b/include/ports.h index ce42043..6b003f6 100644 --- a/include/ports.h +++ b/include/ports.h @@ -1,8 +1,8 @@ /* ports.h - isbadport */ -// RAFA #define NPORTS 30 /* Maximum number of ports */ +/* avr specific values. Original saved under orig/ folder */ + #define NPORTS 3 /* Maximum number of ports */ -// RAFA #define PT_MSGS 100 /* Total messages in system */ #define PT_MSGS 10 /* Total messages in system */ #define PT_FREE 1 /* Port is free */ #define PT_LIMBO 2 /* Port is being deleted/reset */ diff --git a/include/process.h b/include/process.h index 73374fb..a2df59f 100644 --- a/include/process.h +++ b/include/process.h @@ -19,11 +19,11 @@ /* Miscellaneous process definitions */ -// RAFA #define PNMLEN 16 /* Length of process "name" */ #define PNMLEN 8 /* Length of process "name" */ #define NULLPROC 0 /* ID of the null process */ -// RAFA para AVR +/* avr specific */ + #define PNREGS 38 /* size of saved register area */ #define SSP_L 32 /* saved SP (low) */ #define SSP_H 33 /* saved SP (high) */ @@ -32,16 +32,12 @@ #define SSREG 36 /* saved Status Register */ #define INITPS 0x80 /* initial process SREG (interrupts enabled) */ -// RAFA #define MAXARG 6 #define MAXARG 4 #define INITREG 0 - - /* Process initialization constants */ -// #define INITSTK 4096 /* Initial process stack size */ #define INITSTK 64 /* Initial process stack size */ #define INITPRIO 20 /* Initial process priority */ #define INITRET userret /* Address to which process returns */ @@ -64,7 +60,6 @@ struct procent { /* Entry in the process table */ unsigned char pregs[PNREGS];/* saved context (see ctxsw) */ int pargs; /* initial number of arguments */ - // int parg[MAXARG]; /* arguments */ void * parg[MAXARG]; /* arguments */ int *paddr; /* initial code address */ diff --git a/include/prototypes.h b/include/prototypes.h index f6423a8..adfe8f6 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -1,3 +1,5 @@ +/* avr specific values. Original saved under orig/ folder */ + /* in file addargs.c */ extern status addargs(pid32, int32, int32[], int32,char *, void *); @@ -40,7 +42,6 @@ extern syscall close(did32); extern syscall control(did32, int32, int32, int32); /* in file create.c */ -// RAFA extern pid32 create(void *, uint32, pri16, char *, uint32, ...); extern pid32 create(int (*procaddr)(), int, int, char *, int, ...); /* in file ctxsw.S */ @@ -421,7 +422,6 @@ extern umsg32 recvclr(void); extern umsg32 recvtime(int32); /* in file resched.c */ -//RAFA extern void resched(void); extern int resched(void); extern status resched_cntl(int32); @@ -516,7 +516,6 @@ extern syscall semreset(sid32, int32); extern syscall send(pid32, umsg32); /* in file shell.c */ -// RAFA extern process shell(did32); extern process shell(void); /* in file signal.c */ @@ -555,14 +554,12 @@ extern devcall ttycontrol(struct dentry *, int32, int32, int32); extern devcall ttygetc(struct dentry *); /* in file ttyhandle_in.c */ -// RAFA extern void ttyhandle_in(struct ttycblk *, struct uart_csreg *); extern void ttyhandle_in(struct ttycblk *, struct uart_csreg *, char c); /* in file ttyhandle_out.c */ extern void ttyhandle_out(struct ttycblk *, struct uart_csreg *); /* in file ttyhandler.c */ -// RAFA extern void ttyhandler(uint32); extern void ttyhandler(uint32, char c, int tipo); /* in file ttyinit.c */ @@ -638,8 +635,6 @@ typedef unsigned int size_t; #define lobyte(x) (unsigned char)(((int)(x))&0xff) - - /* NETWORK BYTE ORDER CONVERSION NOT NEEDED ON A BIG-ENDIAN COMPUTER */ #define htons(x) ( ( 0xff & ((x)>>8) ) | ( (0xff & (x)) << 8 ) ) #define htonl(x) ( (((x)>>24) & 0x000000ff) | (((x)>> 8) & 0x0000ff00) | \ diff --git a/include/queue.h b/include/queue.h index 8419256..c918a10 100644 --- a/include/queue.h +++ b/include/queue.h @@ -4,10 +4,6 @@ /* Default # of queue entries: 1 per process plus 2 for ready list plus */ /* 2 for sleep list plus 2 per semaphore */ - -// RAFA OJO (quitar): -// #define NQENT (NPROC + 4) - #ifndef NQENT #define NQENT (NPROC + 4 + NSEM + NSEM) #endif @@ -17,9 +13,6 @@ #define MINKEY 0x80000000 /* Min key that can be stored in queue */ struct qentry { /* One per process plus two per list */ - // RAFA int32 qkey; /* Key on which the queue is ordered */ - // RAFA qid16 qnext; /* Index of next process or tail */ - // RAFA qid16 qprev; /* Index of previous process or head */ char qkey; /* Key on which the queue is ordered */ qid16 qnext; /* Index of next process or tail */ qid16 qprev; /* Index of previous process or head */ diff --git a/include/ramdisk.h b/include/ramdisk.h index dab730c..a5ee9d3 100644 --- a/include/ramdisk.h +++ b/include/ramdisk.h @@ -2,8 +2,8 @@ /* Ram disk block size */ -#define RM_BLKSIZ 5 /* block size */ -#define RM_BLKS 2 /* number of blocks */ +#define RM_BLKSIZ 512 /* block size */ +#define RM_BLKS 200 /* number of blocks */ struct ramdisk { char disk[RM_BLKSIZ * RM_BLKS];